Regex Tester
Regex Tester runs a JavaScript regular expression against your text as you type, highlighting every match and listing capture groups. Matching happens in a background thread with a two-second limit, so a pattern that backtracks catastrophically is stopped instead of freezing the page.
Runs entirely in your browser — nothing you enter is uploaded.
DeveloperThis is the JavaScript flavour — the one your browser and Node run. Lookbehind, named groups and unicode escapes work; PCRE-only features like recursion and possessive quantifiers do not.
About regular expressions
This is the JavaScript flavour — the one your browser and Node run — so
lookbehind, named groups and unicode escapes work, while PCRE-only features
such as recursion and possessive quantifiers do not. Flags change the match
rather than the pattern: g finds every match rather than the
first, i ignores case, m makes the anchors match at
each line, and s lets a dot match a newline.
The two-second limit exists for a real failure mode. A quantifier inside
another quantifier, such as (a+)+, lets the engine split the same
text in exponentially many ways; on a string that nearly matches but fails at
the end, it tries all of them. Thirty characters can mean over a billion
attempts. On a server that is a denial-of-service bug; here the work runs off
the main thread, so the page stays usable and the attempt is abandoned.
Common questions
- Why did my pattern get stopped after two seconds?
- Because it backtracks catastrophically on that input. A quantifier nested inside another, such as (a+)+, can divide the same text in exponentially many ways, and on a near-match that fails at the end the engine tries every one. Removing the nesting, or making the inner part unambiguous, fixes it — and the same pattern would hang a server.
- What is the difference between greedy and lazy quantifiers?
- A greedy quantifier such as .* takes as much as it can and gives characters back until the rest of the pattern fits; a lazy one, written .*?, takes as little as possible and expands only as needed. Matching HTML tags shows it: <.*> spans from the first tag to the last, while <.*?> matches each tag separately.
- Why does my expression behave differently in Python or PCRE?
- Because there is no single regular expression language. Flavours differ in features and occasionally in what identical syntax means. Go and Rust use engines that guarantee linear time but have no backreferences or lookaround; PCRE adds recursion and atomic groups that JavaScript lacks. This tester runs the JavaScript flavour.
- Is the text I paste sent anywhere?
- No. The pattern and the text are matched inside your browser, in a background thread, and neither is transmitted. That matters here because testing a pattern usually means pasting real data — log lines, customer records, tokens — which is exactly the material you would not want uploaded to try out a regex.