Regex Tester

Test and debug regular expressions with real-time match highlighting.

Write and test regular expressions against your own text. Matches are highlighted as you type, with the number of matches and capture groups, and a table of each match's position, groups and named groups. Turn flags on and off (global, ignore case, multiline, dot matches newline and Unicode), and try a replacement with $1, $2 or $<name> to see the result before you use it in code. The tester uses your browser's JavaScript regex engine, which handles most patterns the same way as Python, Java and PCRE; lookbehind and named groups work in all current browsers.

//gm

Use $1, $2 or $<name> to insert captured groups, $& for the whole match.

Uses your browser's JavaScript regex engine (the same syntax as Node.js and TypeScript).

Common use cases

  • Build a pattern to validate input such as postcodes or IDs
  • Debug a regex that matches too much or too little
  • Test a find-and-replace before running it on a file
  • Learn regular expressions by experimenting

How to use

  1. Type your pattern without the surrounding slashes.
  2. Paste test text and tick the flags you need.
  3. Check the highlighted matches and the groups table.
  4. Optionally enter a replacement to preview the result.

FAQ

Why does my pattern only match once?

Without the g (global) flag, JavaScript stops at the first match. Tick Global to find them all.

Why don't ^ and $ match each line?

By default they match the start and end of the whole text. Turn on the m (multiline) flag to match at each line break.

Will my pattern work in Python or PHP?

Most patterns will. Differences show up in less common features, such as possessive quantifiers and inline flags. The regex cheat sheet lists the common syntax.