Back to All Tools

Regex Tester & Debugger

Test regular expressions with live matching, highlights, and capture groups.

100% Private — Your data never leaves your browser. Everything runs locally on your device.
/ /

What this tester runs

The tool passes your pattern to your browser's own JavaScript regex engine, new RegExp(pattern, flags). So a pattern behaves here the way it behaves in JavaScript code in the same browser. Other languages can give different results. See the last section below.

A worked example. The pattern (\d{4})-(\d{2})-(\d{2}) on the text Due 2025-04-06 and 2026-01-15. gives 2 matches. The first is 2025-04-06 at index 4, with groups 2025, 04 and 06. The second is 2026-01-15 at index 19.

Regex cheat sheet

Every example below was run with the g flag, the default here.

TokenMeaningExample → matches
.Any character except a line breakc.t on cat cut c-t ct → cat, cut, c-t
\d \w \sA digit; a letter, digit or _; a space, tab or line break\w+ on hi_there, 42! → hi_there, 42
[aeiou]One of these characterson regex → e, e
[^0-9]Any character not in the set[^0-9]+ on ab12cd → ab, cd
^ $Start and end of the text (of each line with m)^Hi on Hi, Hi → the first Hi only
\bWord boundary\bcat\b on cat concat → cat (not the one in concat)
* + ?0 or more; 1 or more; 0 or 1colou?r on color colour → both
{2,3}Between 2 and 3 times\d{2,3} on 1 12 1234 → 12, 123
*? +?Lazy: as few as possiblesee Common mistakes below
( )Capture group(ha)+ on hahaha! → hahaha, Group 1 = ha
(?: )Group without capturing(?:ab)+ on ababx → abab
|Either sidecat|dog on cat and dog → cat, dog
(?= ) (?! )Followed by; not followed by\d(?! USD) on 5 USD 7 EUR → 7
(?<= ) (?<! )Preceded by; not preceded by(?<=\$)\d+ on cost $42 and 7 → 42
\Makes a special character literal\$\d+ on cost $42 → $42

The four flags

The tool offers g, i, m and s. g is on by default and finds every match. i ignores upper and lower case, so colou?r also matches COLOUR. m changes ^ and $: on the three lines one, two, three, the pattern ^\w+ matches only one, but with m it matches all three. s lets . match a line break too.

The flags u, y, d and v are not offered. Without u, two things surprise people:

Common mistakes

Slow patterns are stopped after 1.5 seconds

Some patterns take a very long time on text that almost matches. This is called catastrophic backtracking. The classic example is ^(a+)+$ on a line of a's followed by one b. The engine tries every way to split the a's between the inner and outer +, and each extra a roughly doubles the work. We timed it in Node.js, which uses the same V8 engine as Chrome. With 26 a's it took about 0.3 seconds, with 28 about 1 second, and with 29 about 2 seconds. A few more a's take minutes.

So this tool does not run the match on the page itself. It runs it in a Web Worker, a separate background thread, and gives it 1.5 seconds. If the match is not finished by then, the tool stops the worker and shows Stopped after 1.5 seconds: this pattern is too slow on this text. The page and your text stay as they are, and the next change you make starts a fresh run. If a run takes more than a moment, the status line shows Matching… while you wait.

A stopped pattern is a warning for your own code too. In a real program there is usually no time limit, so the same pattern can hang a server or an app. To avoid the problem, do not nest quantifiers, as in (a+)+ or (\w*)*. ^a+$ matches the same text and stays fast.

JavaScript regex compared with other languages

Most basic syntax is the same everywhere. These are the differences you are most likely to meet when a pattern comes from Python, PHP or Java:

So if a pattern works here, test it once more in the language where you will use it.

Frequently Asked Questions

Which regex engine and flags does this tool use?

It uses the JavaScript regex engine built into your browser. You can turn on four flags: g for all matches, i to ignore case, m so that ^ and $ work per line, and s so that the dot also matches a line break. The flags u, y, d and v are not offered.

Why does \p{L} not match letters?

Unicode property escapes such as \p{L} only work with the u flag, and this tool does not offer it. Without u, the pattern \p{L} matches the literal text p{L}. Test such patterns in your own code with the u flag, or use a character range such as [A-Za-z] here.

Can a slow pattern freeze the page?

No. Matching runs in a background thread with a time limit of 1.5 seconds. A pattern with nested quantifiers, such as ^(a+)+$, can take minutes on text that almost matches. The tool stops it and shows a message instead. Rewrite the pattern without nesting, for example ^a+$.

How do I use the copied regex in my code?

Copy Regex puts slashes around your pattern, adds the flags and escapes each slash inside the pattern. So a/b is copied as /a\/b/g, which you can paste into JavaScript code as it is. If you build the regex from a quoted string instead, leave out the outer slashes and flags, and double every backslash.

Why does my pattern work here but not in Python or PHP?

Each language has its own regex rules. Python named groups written as (?P<name>...), possessive quantifiers such as a++, atomic groups and inline flags such as (?i) are errors in JavaScript. Other patterns may run but match differently. Always test the pattern in the language where you will use it.

Is my text sent to a server?

No. The pattern and the test text are matched by your browser. Nothing is uploaded, and nothing is saved when you close the page.