Which regex engine this is
Matching uses your browser's JavaScript RegExp, which implements the ECMAScript regular expression grammar. That is the same engine as Node.js, and it is close to PCRE for everyday patterns, but not identical: there are no possessive quantifiers or atomic groups, no \A/\Z anchors, no inline flags like (?i) in most browsers, and lookbehind must be a recent engine (all current browsers support it). Python's re and Go's RE2 differ in similar ways. If a pattern will be used elsewhere, test it there as well.
Flags
| Flag | Effect |
|---|---|
g | Find all matches instead of stopping at the first. Without it, the tester shows only the first match. |
i | Case-insensitive matching. |
m | ^ and $ match at the start and end of each line, not only of the whole string. |
s | . also matches line breaks. |
u | Treat the pattern and input as Unicode code points; enables \p{Letter} and correct handling of characters outside the BMP such as emoji. |
y | Sticky: match only at the exact lastIndex position. Used by tokenisers. |
v | Unicode sets (ES2024): set subtraction and intersection in character classes, and string properties. Implies u. |
d | Generate start and end indices for each capture group. |
Groups and replacement
Parentheses capture. (?<name>…) gives the group a name, shown in the table header. (?:…) groups without capturing, which is faster and keeps numbering stable. In the replacement field, $1 refers to the first group, $<name> to a named one, and $& to the whole match.
"2024-03-15".replace(/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})/, "$<d>/$<m>/$<y>")
// "15/03/2024"
for (const m of "a1 b22 c333".matchAll(/([a-z])(\d+)/g)) console.log(m[1], m[2]);
Patterns that bite
- Catastrophic backtracking. Nested quantifiers such as
(a+)+$can take exponential time on a non-matching input. If the tester feels slow, this is why; rewrite with a possessive-like structure (a+$) or anchor earlier. - Greedy by default.
<.*>matches from the first<to the last>. Use.*?for the shortest match, or a negated class<[^>]*>, which is also faster. \dand\ware ASCII-only in JavaScript even with theuflag. Use\p{Nd}and\p{L}for Unicode digits and letters.- Empty matches. A pattern like
a*matches the empty string at every position. They are shown as∅in the output. - Escaping in strings. When you paste a pattern into a JavaScript string literal, every backslash must be doubled. Regex literals (
/…/) avoid this.
For the full syntax, see the regex cheat sheet.
Privacy
Pattern and test text are evaluated in your browser. Nothing is sent to a server, and nothing is stored between visits.