Helper-KitCode Tools

Regex Tester

Test regular expressions live: see every match highlighted, inspect capture groups, and try replacements. Slow patterns are stopped safely.

Test text
Matches highlighted
Matches are highlighted here as you type.
Try an example:

More:Regex CheatsheetFind & ReplaceRemove Duplicates

Type a pattern and some text: matches are highlighted as you type, with the position and capture groups (including named groups) of each one. Replace mode shows the text after replacement. This uses JavaScript's regex engine, the same one as in browsers and Node.js, so some features of other languages (such as possessive quantifiers) are not available. Patterns run in the background and stop automatically if they take too long. Everything runs in your browser.

About This Tool

Type a pattern and some text, and every match is highlighted as you type. The match details list each match with its line and column and the value of every capture group, including named groups such as (?<year>\d{4}). All JavaScript flags are available: global, ignore case, multiline, dot all, unicode and sticky. Replace mode shows the text after replacement, using $1, $<name> and $& in the replacement, with copy and download buttons. Patterns run in the background, so the page never freezes. If a pattern takes too long, usually because of catastrophic backtracking, a progress bar and a Stop button appear, and it stops automatically after 3 seconds, keeping any matches already found. The tool uses the JavaScript regex engine, the same as browsers and Node.js. Everything runs in your browser.

Common Use Cases

  • Building and checking a pattern before using it in code
  • Extracting emails, URLs, dates or IDs from text
  • Reformatting text with find and replace, such as changing date formats
  • Finding out why a pattern does not match
  • Checking whether a pattern is slow on long input

Frequently Asked Questions

Which regex flavour does it use?

JavaScript, the same as browsers and Node.js. Most syntax is shared with other languages, but some features, such as possessive quantifiers, are not available.

How do I use capture groups in a replacement?

Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match and $$ for a dollar sign.

Why does my pattern only find one match?

Turn on the g (global) flag to find all matches instead of just the first.

What is catastrophic backtracking?

Patterns with nested repeats, such as (a+)+, can make the engine try a huge number of combinations on some text. The tester stops such patterns after 3 seconds instead of freezing the page.

Was this tool helpful?

More in this category