Skip to content

Commit cde8c33

Browse files
authored
chore: update readme (#305)
1 parent bdef7d5 commit cde8c33

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ Same as `s.appendRight(...)`, except that the inserted content will go _before_
192192

193193
### s.replace( regexpOrString, substitution )
194194

195-
String replacement with RegExp or string. When using a RegExp, replacer function is also supported. Returns `this`.
195+
String replacement with RegExp or string. The `substitution` parameter supports strings and functions. Returns `this`.
196196

197197
```ts
198198
import MagicString from 'magic-string';
199199

200200
const s = new MagicString(source);
201201

202202
s.replace('foo', 'bar');
203+
s.replace('foo', (str, index, s) => str + '-' + index);
203204
s.replace(/foo/g, 'bar');
204205
s.replace(/(\w)(\d+)/g, (_, $1, $2) => $1.toUpperCase() + $2);
205206
```

0 commit comments

Comments
 (0)