Regex Tester

Test and debug JavaScript regular expressions with live match highlighting, capture groups and replace preview. Free and runs locally in your browser.

//

Replace

How to test a regular expression

  1. Type your pattern between the slashes, without the surrounding / characters.
  2. Toggle flags with the checkboxes or type them in the flags box.
  3. Paste the text to search. Matches are highlighted as you type and listed with their capture groups.
  4. Open Replace to preview String.replace() output.

Regex cheat sheet

Frequently asked questions

Which regex flavor does this tester use?

It uses the JavaScript (ECMAScript) regular expression engine built into your browser, the same one used by Node.js, Deno and Bun. Most syntax is shared with PCRE, Python and Java, but lookbehind support, named group syntax and some escapes differ.

What do the g, i, m, s, u and y flags do?

g finds all matches instead of the first, i ignores case, m makes ^ and $ match at line breaks, s lets the dot match newlines, u enables full Unicode mode, and y (sticky) matches only at the current position.

How do I use capture groups in the replacement?

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

Why did the tester stop with a timeout?

Some patterns, such as nested quantifiers like (a+)+, can take exponential time on certain inputs. This is called catastrophic backtracking. The tester runs each pattern in a background worker and stops it after one second so your tab never freezes.