Regex Tester

Check a regular expression against real text and see exactly what it catches. Type a pattern, tick the flags you want, and paste the text to test: you get the number of matches, every match with its position and capture groups, and the text itself with each match highlighted in place. This is the JavaScript engine your browser already runs, so results match what your own code will do.

Type the pattern on its own, or paste a whole literal such as /\d+/gi β€” the slashes are stripped and the flags below are ticked to match.

Flags

Enter a pattern above to see what it matches.

This is the JavaScript flavour of regular expressions β€” your browser's own RegExp engine, the same one Node.js uses. Other engines differ: PCRE, Python, Ruby, Java and grep vary on named-group syntax, lookbehind, atomic groups and possessive quantifiers, so confirm a pattern in the language you will actually run it in. Nothing you type here is uploaded. A pattern with nested quantifiers such as (a+)+b can take a very long time on some inputs and will make the tab unresponsive while it runs.

How to test a regular expression

  1. Type your pattern in the box β€” or paste a whole literal such as /\d+/gi and the slashes and flags are read from it.
  2. Tick the flags you need: g to find every match, i to ignore case, and m, s or u when your pattern needs them.
  3. Paste the text to test against, then read the match count, the list of matches with their index and capture groups, and the highlighted copy of your text below.

When you'd use this

Good to know

Frequently asked questions

Which regular expression flavour is this?

JavaScript's, exactly as your browser implements it. Anything valid in a JavaScript RegExp works here, and anything it rejects shows the browser's own error message. Patterns written for PCRE, Python or Java may need small changes before they behave the same way.

Why do I only see one match?

The g flag is what makes the engine keep going after the first match. If g is unticked, JavaScript returns only the first result, which is the same behaviour your code would get. Tick g to list every match in the text.

Does it show capture groups and named groups?

Yes. Every match is listed with its numbered groups in order, and named groups written as (?...) are listed separately by name. A group that did not take part in the match is marked as such rather than shown as empty.

Is anything I paste uploaded?

No. The pattern and the test text stay in the page β€” the matching is done by your browser's regex engine and nothing is sent anywhere. You can close the tab and nothing is kept.

What do the s and u flags change?

With s, a dot also matches newline characters, which matters when your test text has more than one line. With u, the pattern is read in Unicode mode, so escapes like \u{1F600} and property escapes work and surrogate pairs count as one character.