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
Opting in to astral mode disables the use of `\p{…}` and `\P{…}` within character classes. In astral mode, use e.g. `(\pL|[0-9_])+` instead of `[\pL0-9_]+`.
@@ -168,21 +169,20 @@ Named subpatterns can be provided as strings or regex objects. A leading `^` and
168
169
Provides tagged template literals that create regexes with XRegExp syntax and flags:
169
170
170
171
```js
171
-
XRegExp.match('word', XRegExp.tag()`\w\b`);
172
-
// -> 'd'
173
-
174
-
consth12=/1[0-2]|0?[1-9]/;
175
-
consth24=/2[0-3]|[01][0-9]/;
176
-
consthours=XRegExp.tag('x')`${h12} : | ${h24}`;
177
-
constminutes=/^[0-5][0-9]$/;
178
-
// Note that explicitly naming the 'minutes' group is required for named backreferences
`XRegExp.tag` does more than just basic interpolation. For starters, you get all the XRegExp syntax and flags. Even better, since `XRegExp.tag` uses your pattern as a raw string, you no longer need to escape all your backslashes. And since it relies on `XRegExp.build` under the hood, you get all of its extras for free. Leading `^` and trailing unescaped `$` are stripped from interpolated patterns if both are present (to allow embedding independently useful anchored regexes), interpolating into a character class is an error (to avoid unintended meaning in edge cases), interpolated patterns are treated as atomic units when quantified, interpolated strings have their special characters escaped, and any backreferences within an interpolated regex are rewritten to work within the overall pattern.
185
+
`XRegExp.tag` does more than just interpolation. You get all the XRegExp syntax and flags, and since it reads patterns as raw strings, you no longer need to escape all your backslashes. `XRegExp.tag` also uses `XRegExp.build` under the hood, so you get all of its extras for free. Leading `^` and trailing unescaped `$` are stripped from interpolated patterns if both are present (to allow embedding independently useful anchored regexes), interpolating into a character class is an error (to avoid unintended meaning in edge cases), interpolated patterns are treated as atomic units when quantified, interpolated strings have their special characters escaped, and any backreferences within an interpolated regex are rewritten to work within the overall pattern.
0 commit comments