Regex Tester
Test JavaScript regular expressions live with match highlighting and capture groups.
Type a pattern and some text; results update as you type.
| # | Index | Match | Groups |
|---|
What this tool does
Test a JavaScript regular expression against real text and see every match instantly. Type the pattern without surrounding slashes, tick the flags you need, and paste your sample text: matches are highlighted in place, listed in a table with their position and capture groups (numbered and named), and counted in the status line. Add a replacement string to preview what String.prototype.replace would return, including $1, $& and $<name> references. Invalid patterns show the browser's own error message so you can fix them before pasting the expression into your code. Because the engine is the same one your browser runs, what works here works in Node.js, Deno and front-end code.
Regex cheat sheet
. | Any character except a line break (any character with the s flag) |
\d \w \s | Digit; word character (letters, digits, _); whitespace |
\D \W \S | The opposite of \d, \w and \s |
[abc] [a-z] [^abc] | One character from the set, a range, or anything not in the set |
^ $ | Start and end of the text (of each line with the m flag) |
\b \B | Word boundary; not a word boundary |
a* a+ a? | Zero or more; one or more; zero or one |
a{3} a{2,5} a{2,} | Exactly 3; between 2 and 5; at least 2 |
a*? a+? a?? | Lazy versions: match as little as possible |
a|b | Either a or b |
(…) (?:…) | Capture group; non-capturing group |
(?<name>…) | Named capture group, read with $<name> in replacements |
\1 $1 $<name> | Back-reference in the pattern; group reference in the replacement |
(?=…) (?!…) | Positive and negative lookahead |
(?<=…) (?<!…) | Positive and negative lookbehind |
\. \\ \/ | Escape a special character to match it literally |
\u{1F600} \p{L} | Code point and Unicode property escapes (need the u flag) |
Notes
- Without the g flag only the first match is reported, exactly as regex.exec() behaves.
- Zero-length matches (for example ^ with the m flag, or \b) are shown as thin markers and never cause an endless loop.
- Lookbehind, named groups and Unicode property escapes are supported by every current browser; very old browsers may reject them.
- A pattern with catastrophic backtracking can freeze the tab on long text. Prefer specific character classes over nested quantifiers.
- This tester uses JavaScript syntax. PCRE, Python and Java regexes are mostly compatible, but possessive quantifiers, atomic groups and inline modifiers like (?i) are not available.
Privacy
Patterns and test text are processed in your browser only; nothing is uploaded or stored.