Handy Devtools
Back to tools

Regex Tester

Test and explain JavaScript regular expressions safely.

Processed locally in your browser
//

JavaScript flags: d g i m s u v y · u and v cannot be combined · pattern size 30 bytes · limit 10 KiB

Test text size: 52 bytes · limit 1 MiB

Use $&, $1, and $<name>. The g flag controls whether one or all matches are replaced.

Deterministic explanation

  • (?<word>\b[a-z]+) is a named capture “word”.
  • \b is a word assertion.
  • [a-z]+ repeats its preceding token from 1 to unlimited times.
  • [a-z] matches one character from inside the class.
  • \s+ repeats its preceding token from 1 to unlimited times.
  • \s is a character set or escape.
  • \b is a word assertion.

About this tool

This tester uses the browser’s JavaScript RegExp engine. Matching and replacement run in a disposable worker with a 500 ms deadline, while explanations come from the regexpp syntax tree rather than generated guesses.

How to use it

  1. Enter a JavaScript pattern and supported browser flags.
  2. Add test text and optional JavaScript replacement syntax.
  3. Inspect match indices, capture groups, highlighted boundaries, output, and the parsed explanation.

Flags and matches

  • Without g, JavaScript returns and replaces only the first match. With g, all matches are processed up to the 1,000-item display cap.
  • The u and v Unicode modes describe different grammars and are mutually exclusive. Support for v depends on the browser engine.

Zero-width matches and safety

  • Zero-width matches have identical start and end indices, so they appear in match details without manufacturing highlighted text.
  • A timeout reduces the risk from hostile backtracking, but it cannot prove a pattern is efficient for every input.

Frequently asked questions

Does this use PCRE syntax?

No. It supports JavaScript regular expressions only, using the flags and replacement behavior implemented by your browser.

Can a regex still be dangerous?

Yes. Backtracking cost depends on both pattern and input. Work is terminated after 500 ms, but production code should still constrain input and review complex expressions.

Related developer tools