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.
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
- Type your pattern in the box β or paste a whole literal such as /\d+/gi and the slashes and flags are read from it.
- Tick the flags you need: g to find every match, i to ignore case, and m, s or u when your pattern needs them.
- 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
- Checking a pattern before you ship it β Run it against real sample data and confirm it catches every case you expect, not just the first one.
- Fixing a pattern that matches too much β The highlighted text shows precisely which characters were consumed, which is usually where a greedy quantifier went wrong.
- Working out capture groups β Each match lists its numbered groups and any named groups, so you know which index holds which part.
- Learning regex syntax β Change one character at a time and watch the match list update as you type, without setting up a scratch file.
Good to know
- This is the JavaScript flavour β Patterns run through the browser's own RegExp object, so what you see here is what String.match, replace and test will do. PCRE, Python, Ruby and Java differ on named-group syntax, lookbehind, atomic groups and a few escapes.
- Zero-width matches are handled β Patterns such as \b or (?=x) match an empty string. With the g flag the tool steps past each one so the scan always finishes, and shows them as a thin marker in the highlighted text rather than nothing at all.
- Long scans stop early on purpose β The match list stops at 5,000 matches and highlighting at the first 2,000, so a huge input cannot lock the page up. When that happens the result says so instead of quietly truncating.
- A slow pattern can still freeze the tab β Nested quantifiers like (a+)+b can take an extremely long time on certain inputs. That is the regex engine itself, not this page β if the tab stops responding, reload it and simplify the pattern.
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 (?
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.