Skip to content

regexMatchNotation

Reports inconsistent notations for matching any character in regular expressions.

✅ This rule is included in the ts stylisticStrict presets.

Reports inconsistent notations for matching any character in regular expressions. There are multiple ways to match any character: [\s\S], [\S\s], [\d\D], [\w\W], [^], and . with the s (dotAll) flag. This rule enforces using [\s\S] as the standard notation.

const pattern = /[\S\s]/;
const pattern = /[^]/;
const pattern = /[\d\D]/;
const pattern = /[\w\W]/;

This rule is not configurable.

If your team has established a different convention for matching any character, or if you prefer the flexibility of using different notations in different contexts, you might want to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.