Regex Tester for JavaScript
Test JavaScript-compatible regular expressions. Live matches, groups, and error hints. Runs in your browser.
Matches
โ use $1, $<name>, $&
Match details
How to use this regex tester
- Enter a pattern without slashes, e.g.
\b\w+@\w+\.\w+\b, and optional flags such asgi. - Paste the text to test against โ matches are highlighted as you type.
- Inspect each match with its index and capture groups (including named groups) in the details panel.
Regex cheat sheet
| Token | Matches |
|---|---|
. | Any character except line breaks (use the s flag to include them) |
\d \w \s | Digit, word character [A-Za-z0-9_], whitespace |
\D \W \S | The opposite of the above |
[abc] [^abc] [a-z] | Character set, negated set, range |
^ $ | Start / end of input (of each line with m) |
\b | Word boundary |
* + ? | 0 or more, 1 or more, 0 or 1 (add ? for lazy: *?) |
{3} {2,5} | Exactly 3, between 2 and 5 |
(โฆ) (?:โฆ) | Capturing group, non-capturing group |
(?<name>โฆ) | Named capturing group |
a|b | Alternation โ a or b |
(?=โฆ) (?!โฆ) | Positive / negative lookahead |
(?<=โฆ) (?<!โฆ) | Positive / negative lookbehind |
Flags
g | Global โ find all matches, not just the first |
i | Case-insensitive |
m | Multiline โ ^ and $ match at line breaks |
s | Dot-all โ . also matches newlines |
u | Unicode โ correct handling of code points and \p{โฆ} classes |
y | Sticky โ match only at the current position |
Useful patterns
| Email (simple) | ^[^\s@]+@[^\s@]+\.[^\s@]+$ |
| Date YYYY-MM-DD | ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ |
| Hex color | ^#?([0-9a-f]{3}|[0-9a-f]{6})$ with i |
| IPv4 address | ^((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)$ |
| Whitespace at line ends | [ \t]+$ with gm |
Frequently asked questions
Which regex engine is used?
The JavaScript RegExp engine built into your browser (ECMAScript). Results match what Node.js and browsers do.
How is JavaScript regex different from PCRE (PHP) or Python?
Most syntax is the same. JavaScript has no possessive quantifiers or atomic groups, sets flags after the pattern rather than with (?i) prefixes, and uses (?<name>โฆ) for named groups.
Why does my pattern only find one match?
Without the g (global) flag, only the first match is returned. Add g to find all matches.
How do I match across multiple lines?
Use the m flag so ^ and $ match at each line, and the s flag so . also matches newline characters.
Do I need to escape slashes?
No. Enter the pattern without surrounding /โฆ/ delimiters; slashes inside the pattern do not need escaping here.
Is my text uploaded?
No. All matching happens client-side in your browser.