Regex Tester

Test patterns live with highlighting, groups, replace preview and a cheat sheet.

Free No sign-up Runs in your browser Developer

Presets

Highlighted matches

Matches

#MatchIndexGroups

Cheat sheet

Catastrophic backtracking, and why this tester survives it

JavaScript regexes backtrack. A pattern like (a+)+$ against a few dozen characters takes exponential time — not a slow frame, but a permanently frozen tab you have to force-quit. In a tester that re-runs on every keystroke, that is reachable by typing an ordinary-looking pattern.

A timeout alone does not fix it: abandoning the promise leaves the computation burning a core. Every evaluation here therefore runs in a Web Worker that is terminated when it exceeds 800 ms, which is the only way to actually stop the work. If that happens you get a clear message instead of a dead page.

Flags

  • g — find every match rather than only the first
  • i — case-insensitive
  • m^ and $ match at each line, not just the whole string
  • s. also matches newlines

About the presets

The email pattern is deliberately pragmatic rather than RFC 5322 — the full grammar is famously unreadable and accepts addresses no mail provider will ever issue. The IPv4 pattern range-checks each octet, so it rejects 999.999.999.999, which the naive \d{1,3} version happily accepts. Every sample contains both passing and failing lines, so you can see what a pattern rejects as well as what it accepts.

Groups and replacement

Capture groups appear per match as $1, $2 and so on, and named groups (?<name>…) are listed by name. In the replacement field $& inserts the whole match and $1 a group, so [$&] wraps every match in brackets.

Related tools

Browse all 45 tools