Regex Tester
Write a pattern, paste test text and see every match highlighted. Step through matches to inspect capture groups and positions. Uses your browser's JavaScript regex engine.
Runs entirely in your browser. Your text is not uploaded.
2 matches
Highlighted
Write to ana.lopez@example.com or press+team@news.example.co.uk. Not an address: me@localhost
Match 1 of 2
| Full match | ana.lopez@example.com |
| Position | 9–30 |
| Group 1(user) | ana.lopez |
| Group 2(domain) | example.com |
Cheat sheet
. | any character except newline |
\d \w \s | digit, word character, whitespace |
\D \W \S | not digit, word, whitespace |
[abc] [^abc] | one of / none of |
a* a+ a? | 0 or more, 1 or more, optional |
a{2,4} | 2 to 4 times |
a*? | lazy (as few as possible) |
^ $ | start / end (of line with m) |
\b | word boundary |
(…) (?:…) | capture group / non-capturing |
(?<name>…) | named group |
(?=…) (?!…) | lookahead / negative |
(?<=…) (?<!…) | lookbehind / negative |
\p{L} | any letter, any language (u flag) |
a|b | a or b |
How to use the regex tester
- Type a pattern without the surrounding slashes.
- Toggle flags: g, i, m, s, u, y.
- Step through matches and read each capture group.
Patterns worth keeping
^\s*$with the m flag: blank lines.\b(\w+)\s+\1\b: doubled words like “the the”.(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}): ISO dates with named groups.\p{Lu}\p{Ll}+with the u flag: capitalised words in any alphabet.
To apply a pattern to text and replace matches, use find and replace with regex switched on.
Questions
Which regex flavour does this use?
JavaScript (ECMAScript) as implemented by your browser. It supports lookbehind, named groups, Unicode property escapes like \p{L} with the u flag, and the s flag. PCRE-only features such as possessive quantifiers are not available.
Why does my pattern only find one match?
Without the g (global) flag a regex stops at the first match. It is on by default here.
What does the u flag change?
It makes the engine treat emoji and other astral characters as single characters and enables \p{…} escapes. Without it, "." matches half of an emoji.