Regex Tester

Type a pattern and see every match highlighted as you go, with capture groups in a table and a live replace preview. Uses your browser’s JavaScript engine.

Processed locally in your browser
/ /
Test string
Matches
Enter a patternJavaScript (ECMAScript) regex engine

Groups

Replace


Examples

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

FlagEffect
gFind all matches instead of stopping at the first. Without it, the tester shows only the first match.
iCase-insensitive matching.
m^ and $ match at the start and end of each line, not only of the whole string.
s. also matches line breaks.
uTreat the pattern and input as Unicode code points; enables \p{Letter} and correct handling of characters outside the BMP such as emoji.
ySticky: match only at the exact lastIndex position. Used by tokenisers.
vUnicode sets (ES2024): set subtraction and intersection in character classes, and string properties. Implies u.
dGenerate 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.
  • \d and \w are ASCII-only in JavaScript even with the u flag. 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.

navigateEnter openEsc close