RUN

Regex Tester

Write a regular expression and see every match, capture group and replacement as you type.

Runs in your browser · nothing is uploaded

How to use the Regex Tester

  1. Type your pattern between the slashes, without the slashes themselves, and pick flags such as g (all matches), i (ignore case) or m (multiline).
  2. Paste the text to search. Matches are highlighted as you type and listed below with their position and capture groups.
  3. Type a replacement, using $1, $2 or $<name> for groups, to preview the result of String.replace.
  4. If the pattern has a syntax error, the message explains it. Patterns that run too long are stopped automatically.

About this tool

This tester uses your browser’s JavaScript regex engine, so results match exactly what RegExp, String.match, matchAll and replace do in JavaScript and TypeScript, in the browser and in Node.js. Most simple patterns behave the same in Python, Java and other languages, but lookbehind, named groups and some flags differ, so test those in the target language too, for example in our Python compiler.

Each match lists its index, the full matched text and every capture group, including named groups written as (?<name>...). The replace box shows what your replacement string produces, which is the quickest way to get $1 and $<name> references right.

Some patterns, such as (a+)+$ on a long string, take exponential time to fail. That is called catastrophic backtracking, and it can hang a page or a server. Here the pattern runs in a background worker that is stopped after a moment, so the page stays responsive and you learn the pattern is dangerous before it reaches production.

Frequently asked questions

›Which regex flavour does this use?

JavaScript (ECMAScript), as built into your browser. It supports lookahead and lookbehind, named groups, Unicode property escapes with the u flag, and the d, g, i, m, s, u, v and y flags.

›Why does only one match show?

Without the g (global) flag, JavaScript stops at the first match. Turn on g to see all of them.

›How do I match a dot or a bracket literally?

Escape it with a backslash: \. matches a dot, \( a bracket. Inside a character class like [.] most characters are already literal.

›What does the m flag change?

With m, ^ and $ match at the start and end of every line, not only of the whole text.

›Is my data sent anywhere?

No. The tool runs entirely in your browser with JavaScript. What you paste is never uploaded, logged or stored on our servers, so it is safe to use with internal data, though you should still treat secrets with care on shared computers.