Regex tester
Write a regular expression and see every match highlighted as you type, with capture groups listed and a find-and-replace preview. Uses the JavaScript regex engine.
Matches
| # | Match | Index | Groups |
|---|
Runs entirely in your browser. Nothing you enter is sent to a server.
Quick reference
. | Any character except newline | \d \w \s | Digit, word character, whitespace |
^ $ | Start / end of string (or line with m) | \b | Word boundary |
* + ? | 0+, 1+, 0 or 1 times | {2,5} | Between 2 and 5 times |
[abc] [^abc] | Any of / none of | (…) (?<name>…) | Capture group, named group |
a|b | a or b | (?=…) (?!…) | Lookahead, negative lookahead |
Handy patterns
- Canadian postal code:
[A-Z]\d[A-Z] ?\d[A-Z]\d(with the i flag) - Email (simple check):
^[^\s@]+@[^\s@]+\.[^\s@]+$ - North American phone:
\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4} - ISO date:
\d{4}-\d{2}-\d{2}
Cleaning up lists after matching? Sort and de-duplicate with the line tools, or compare before and after with the diff checker.
Frequently asked questions
Which regex flavour does this use?
Your browser’s JavaScript (ECMAScript) engine, which supports lookbehind, named groups and Unicode property escapes like \p{L} with the u flag.
Will patterns work in Python or PHP?
Most simple patterns do. Differences appear in advanced features such as possessive quantifiers, inline flags and some escape sequences.
Why does my pattern only find one match?
Add the g (global) flag to find every match.