Regex Tester
Type a pattern and see every match highlighted as you go, with groups, flags, a live replace preview and a cheat sheet.
Pattern
Test string
Highlighted matches
Match list
Replace
Use $1, $2… for groups, $<name> for named groups, $& for the whole match.
Cheat sheet
| Token | Meaning |
|---|---|
| \d \w \s | Digit · word character (letter, digit, _) · whitespace. Capitals (\D \W \S) negate. |
| . | Any character except a line break (with the s flag, line breaks too) |
| * + ? | Zero or more · one or more · zero or one. Add ? after for a lazy (shortest) match. |
| {n} {n,} {n,m} | Exactly n · at least n · between n and m repetitions |
| [abc] [^abc] [a-z] | Character class · negated class · range |
| (…) (?:…) (?<name>…) | Capturing group · non-capturing group · named group |
| a|b | Alternation — match a or b |
| ^ $ | Start · end of string (of each line with the m flag) |
| \b | Word boundary (\B = not a boundary) |
| (?=…) (?!…) | Positive · negative lookahead |
| (?<=…) (?<!…) | Positive · negative lookbehind |
| \1 \k<name> | Back-reference to group 1 · to a named group |
About this tool
Regular expressions are powerful and unforgiving: one misplaced bracket and your validation silently rejects every email, or your log parser grabs the wrong column. This free regex tester lets you see exactly what a pattern does before it goes into code. Type the expression, toggle the g i m s u y flags, paste a sample of real text, and every match is highlighted live with its position, numbered groups and named groups listed beside it. Invalid patterns show the engine's actual error message rather than a blank result.
The Replace panel previews String.replace with $1, $<name> and $& references, which makes it a quick way to build search-and-replace transformations for editors and scripts. A cheat sheet of the most common tokens — classes, quantifiers, anchors, groups, lookarounds — sits at the bottom for reference. Everything runs in your browser with the native JavaScript RegExp engine, so pasted logs, source code and customer data never leave your machine, and results appear as fast as you can type.
How to test a regular expression
- Enter your pattern (without the surrounding slashes) and tick the flags you need.
- Paste sample text — matches are highlighted and listed with their groups as you type.
- Optionally add a replacement string to preview the substituted text, then copy it.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript's built-in RegExp engine — the same one used by Node.js and every browser. Most patterns from Python, PCRE or Java work unchanged, but a few constructs differ: JavaScript has no possessive quantifiers or atomic groups, and lookbehind and named groups require a modern browser.
Why does it only show one match?
Without the g (global) flag a regular expression stops after the first match, which is also how String.replace behaves. Tick g to find and highlight every match in the text; the match list and count update immediately.
How do I use capture groups in the replacement?
Write $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign — exactly the syntax JavaScript's replace method accepts. The replaced output updates live so you can see the effect of each edit.
What happens if my pattern is invalid?
The tester shows the engine's own error message, such as an unterminated group or a bad escape, instead of silently matching nothing. Fix the pattern and the highlighting returns as soon as it compiles again.
Is the text I paste kept private?
Yes. Matching and replacing happen in your browser with the native RegExp engine, so log excerpts, customer data and source code never leave your machine. To keep the page responsive the test string is capped at 100,000 characters.