Matches

JavaScript regex flags

FlagNameEffect
gglobalFind every match, not just the first.
icase-insensitiveLetters match regardless of case.
mmultiline^ and $ match line breaks.
sdotall. matches newline characters.
uUnicodeTreat the pattern as a Unicode sequence.
ystickyMatch only at lastIndex.
dindicesMatch result includes start/end indices for groups.

FAQ

Why is my pattern not matching?

Common causes: forgetting to escape ., ?, or + when matching them literally; using . across newlines without the s flag; using ^/$ across lines without the m flag.

Why is one pattern very slow?

Catastrophic backtracking. Patterns with nested quantifiers like (a+)+ can explode on certain inputs. Restructure with atomic groups (where supported) or anchor more strictly.

Is this the same regex as Python or PCRE?

No. JavaScript's engine supports most PCRE features but has differences in lookbehind support across older browsers, named capture syntax, and some Unicode property escapes. Test in the engine you'll deploy against.