You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,9 +165,9 @@ Same as `s.appendLeft(...)`, except that the inserted content will go *before* a
165
165
166
166
Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
167
167
168
-
### s.replace( regexp, substitution )
168
+
### s.replace( regexpOrString, substitution )
169
169
170
-
String replacement with RegExp or string, a replacer function is also supported. Returns `this`.
170
+
String replacement with RegExp or string. When using a RegExp, replacer function is also supported. Returns `this`.
171
171
172
172
```ts
173
173
importMagicStringfrom'magic-string'
@@ -183,6 +183,11 @@ The differences from [`String.replace`]((https://developer.mozilla.org/en-US/doc
183
183
- It will always match against the **original string**
184
184
- It mutates the magic string state (use `.clone()` to be immutable)
185
185
186
+
### s.replaceAll( regexpOrString, substitution )
187
+
188
+
Same as `s.replace`, but replace all matched strings instead of just one.
189
+
If `substitution` is a regex, then it must have the global (`g`) flag set, or a `TypeError` is thrown. Matches the behavior of the bultin [`String.property.replaceAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll).
190
+
186
191
### s.remove( start, end )
187
192
188
193
Removes the characters from `start` to `end` (of the original string, **not** the generated string). Removing the same content twice, or making removals that partially overlap, will cause an error. Returns `this`.
0 commit comments