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: docs/src/rules/require-unicode-regexp.md
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -182,3 +182,27 @@ const fooRegexp = new RegExp('foo', 'v');
182
182
## When Not To Use It
183
183
184
184
If you don't want to warn on regular expressions without either a `u` or a `v` flag, then it's safe to disable this rule.
185
+
186
+
### Note on `i` flag and `\w`
187
+
188
+
In some cases, adding the `u` flag to a regular expression using both the `i` flag and the `\w` character class can change its behavior due to Unicode case folding.
189
+
190
+
For example:
191
+
192
+
```js
193
+
const regexWithoutU = /^\w+$/i;
194
+
const regexWithU = /^\w+$/iu;
195
+
196
+
const str = "\u017f\u212a"; // Example Unicode characters
197
+
198
+
console.log(regexWithoutU.test(str)); // false
199
+
console.log(regexWithU.test(str)); // true
200
+
```
201
+
202
+
If you prefer to use a non-Unicode-aware regex in this specific case, you can disable this rule using an `eslint-disable` comment:
0 commit comments