Skip to content

Commit b8c534e

Browse files
committed
Fix README replace example for when namespacing is on (#316)
1 parent c4a83e7 commit b8c534e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ while (match = XRegExp.exec('<1><2><3>4<5>', /<(\d+)>/, pos, 'sticky')) {
3535
// XRegExp.replace allows named backreferences in replacements
3636
XRegExp.replace('2017-02-22', date, '$<month>/$<day>/$<year>');
3737
// -> '02/22/2017'
38-
XRegExp.replace('2017-02-22', date, (match) => {
39-
return `${match.groups.month}/${match.groups.day}/${match.groups.year}`;
38+
XRegExp.replace('2017-02-22', date, (...args) => {
39+
const groups = args.pop();
40+
return `${groups.month}/${groups.day}/${groups.year}`;
4041
});
4142
// -> '02/22/2017'
4243

0 commit comments

Comments
 (0)