Loading Techie Utils…

Regex Tester & Debugger

Test patterns, inspect groups and preview replacements. Free, and runs entirely in your browser — nothing you enter is uploaded or stored.

About Regex Tester

Write a pattern, tick the flags, and every match in the test string is highlighted in place — neighbouring matches in alternating shades so they stay apart — with a table of each match, where it starts, and what every capture group caught, named groups included.

Underneath sits the part that turns a pattern from a wall of punctuation into something readable: the expression is taken apart token by token and explained in words, indented to follow its own nesting. (?<=\b) is a look-behind, [^a-z0-9_] is any character that is not a letter, a digit or an underscore, {2,5} is between two and five times. It is the fastest way to read someone else's regular expression, or to find out why yours does not mean what you thought.

Patterns that are known to go wrong are called out: a repeated group that itself repeats is the shape behind most regular-expression denial of service, and two greedy wildcards in a row make the engine try every split between them. Add a replacement and the substitution is previewed before you run it against anything real.

This uses the browser's own regular expression engine, so what you see here is what JavaScript will do — including its specific behaviour for lookbehind, named groups and Unicode escapes. Patterns from Python, PCRE or Go may need adjusting.

Where it helps

  • Explains the pattern token by token, indented to follow its nesting — the quickest way to read a regular expression you did not write.
  • Matches and capture groups are shown together in a table, named groups included, so you can see what each group caught.
  • Replacement preview with $1 style references, before you touch production data.
  • Every match is listed with its position in the string, so you can see what was skipped.
  • Everything is local — test against real log lines without uploading them.

Limits

  • JavaScript flavour only; PCRE features such as atomic groups and recursion are unavailable.
  • A catastrophically backtracking pattern will hang this page just as it would hang your server — the warnings point at the shapes that cause it, but they cannot catch every one.
  • Highlighting shows matches, not why a pattern failed to match, and only the first 500 matches are listed.
  • Regular expressions cannot parse nested structures — HTML and JSON need real parsers.

Frequently asked questions

Do I need the g flag here?

It is ticked by default, and applied anyway when nothing else would find more than one match, so you always see every match. Your own code still needs it, which is the usual reason a pattern behaves differently there.

Is the explanation the engine's own reading of the pattern?

It is a separate reading, written to be understood rather than executed. The matching itself is done by the browser's engine, so where the two could ever disagree, the matches are the truth.

What do the common flags do?

g finds every match, i ignores case, m makes ^ and $ match at line boundaries, s lets . match newlines, and u enables full Unicode handling.

Why does my pattern work in Python but not here?

Flavours differ. (?P<name>…) becomes (?<name>…), and PCRE-specific constructs have no JavaScript equivalent.

How do I reference a capture group in the replacement?

$1, $2 and so on by position, or $<name> for a named group. $& inserts the whole match.

Related tools

More Web Development tools