Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Free tools / Regex tester
Free tool · runs in your browser

Regex tester live matches

Type a pattern and some text: matches, groups and replacements update as you type. A pattern that hangs is stopped after 2 seconds.

Which regex flavour is this?

JavaScript (ECMAScript), as in browsers and Node.js. Most syntax is shared with Python, Java, PCRE and Go, but some isn't: lookbehind (?<=…) works here; possessive quantifiers a++ and atomic groups (?>…) don't; named groups are (?<name>…); in replacements use $1 and $<name> (Python uses \1).

Cheat sheet

\d \w \sdigit, word character, whitespace (capital = the opposite)
. any character except newline (with s: any character)
* + ? {2,5}0+, 1+, 0 or 1, between 2 and 5 times; add ? to make them lazy
^ $ \bstart, end (per line with m), word boundary
[a-z] [^0-9]character class, negated class
(…) (?:…) (?<n>…)capture, non-capturing, named group
(?=…) (?!…) (?<=…)lookahead, negative lookahead, lookbehind

Why this tester stops slow patterns (ReDoS)

Patterns with nested quantifiers, like (a+)+$, can take exponential time on input that almost matches. OWASP calls this Regular expression Denial of Service: one request with crafted input can tie up a server. Here every test runs in a background worker and is stopped after 2 seconds, so the page never freezes. If a pattern is stopped, rewrite it before using it on user input.

Sources