How it works
Patterns run with your browser’s JavaScript engine (ECMAScript flavor), in a Web Worker. If a pattern takes more than 500 ms (catastrophic backtracking, as with (a+)+$ on a long string), the worker is stopped and the page stays responsive.
Flags
| Flag | Effect |
|---|---|
g |
find all matches, not just the first |
i |
case-insensitive |
m |
^ and $ match at line breaks |
s |
. also matches newlines |
u |
Unicode mode: \u{…}, \p{…} property escapes, stricter syntax |
y |
sticky: match only at lastIndex |
Replacement syntax
$1…$99 numbered group · $<name> named group · $& whole match · $` text before · $' text after · $$ a literal $.
Differences from other flavors
No possessive quantifiers or atomic groups (PCRE), no (?i) inline flags in most engines, and lookbehind must be fixed or bounded in some older browsers. Test in the flavor your code actually uses.