How to use the regex tester
- Type your pattern between the slashes — without the slashes themselves — and set flags with the checkboxes or the small box after the closing slash.
- Paste sample text. Every match is highlighted and counted immediately.
- Check the Match details table for the position of each match and the content of each capture group.
- Enter a replacement to preview what
text.replace(regex, replacement)would produce. Use$1,$2… for numbered groups,$<name>for named groups and$&for the whole match.
The tester uses your browser's JavaScript regex engine, so results are exactly what your JavaScript or TypeScript code will do. Other languages (PCRE in PHP, Python's re, Java, .NET) are very similar for everyday patterns but differ in advanced features.
Quick reference
| Pattern | Matches |
|---|---|
. | Any character except a line break (any at all with the s flag) |
\d \w \s | Digit, word character (letter, digit, _), whitespace. Uppercase = the opposite. |
[abc] [^abc] [a-z] | One of, none of, a range |
* + ? {2,5} | 0 or more, 1 or more, optional, between 2 and 5 times. Add ? to make them lazy. |
^ $ | Start and end of the text (of each line with m) |
\b | Word boundary |
(…) (?:…) (?<name>…) | Capture group, non-capturing group, named group |
a|b | Either a or b |
(?=…) (?!…) (?<=…) (?<!…) | Lookahead, negative lookahead, lookbehind, negative lookbehind |
Protection against runaway patterns
Some patterns, like (a+)+$ applied to a long string of “a”s followed by another character, take exponential time to fail — known as catastrophic backtracking, and the cause of real-world outages (ReDoS). Many online testers freeze the whole browser tab when this happens. Here, the matching runs in a background worker that is stopped after 1.5 seconds, and you get a warning instead. If you see it, make your quantifiers more specific or avoid nesting them.
Frequently asked questions
Which regex flavor does this use?
JavaScript (ECMAScript) regular expressions, as implemented by your browser. That includes named groups, lookbehind, Unicode property escapes like \p{L} with the u flag, and the s (dotAll) flag.
Why does my regex only find one match?
Without the g (global) flag, JavaScript stops at the first match. Tick “g — all matches”.
How do I match a literal dot, slash or parenthesis?
Escape it with a backslash: \. \/ \( \). Inside square brackets most characters don’t need escaping, except ] \ ^ and -.
Is my text uploaded?
No. Matching happens in a Web Worker inside your browser; nothing is sent to a server.