Developer

Regex Tester

Test JavaScript regular expressions with highlighted matches, capture groups and replacements, safely stopped if a pattern runs away.

/ /g

About this tool

Write a regular expression and see every match highlighted in your test text as you type. Click a match to see its position and capture groups, named ones included, and turn on replacing to preview the result with $1 or $<name> references.

Patterns run in a separate worker with a time limit. Some patterns, like (a+)+$, take exponentially longer on text that almost matches; instead of freezing the page, the run is stopped and you’re told why. Nested repeats are also flagged as you type.

These are JavaScript regular expressions with every flag your browser supports, including d, s, u, v and y. Other languages’ engines differ in places, so test with the engine you’ll use when it matters.

What is catastrophic backtracking?

When a pattern can match the same text in many ways, like (a+)+, a failing match tries every combination, which grows exponentially with the text length. Rewrite the pattern so each part of the text can only be matched one way.

esc
  • Opens in its own window, like any app
  • Works without an internet connection
  • Starts instantly from your home screen or dock

Look for the install icon at the right end of your browser’s address bar, or open the browser menu and choose Install Interformat.