Test regex with live highlights, groups and replace preview.
Updated
Pattern
//g
Test string
Thequickbrownfoxjumpsoverthelazydog.
Matches (9)
"The"at 0, length 3
$1:
The
word:
The
"quick"at 4, length 5
$1:
quick
word:
quick
"brown"at 10, length 5
$1:
brown
word:
brown
"fox"at 16, length 3
$1:
fox
word:
fox
"jumps"at 20, length 5
$1:
jumps
word:
jumps
"over"at 26, length 4
$1:
over
word:
over
"the"at 31, length 3
$1:
the
word:
the
"lazy"at 35, length 4
$1:
lazy
word:
lazy
"dog"at 40, length 3
$1:
dog
word:
dog
Replace
Quick start
How to test a regex in your browser
Type a pattern, flip flags, paste test text, see live highlights and captured groups.
Step 1
Write your pattern
Type the pattern (without the surrounding slashes). Toggle g / i / m / s / u / y flags as needed.
Step 2
Paste test text
Drop the string to test against. Matches highlight live and group values appear in the list below.
Step 3
Try a replacement
Enable the Replace pane to preview replacements with $1, $<name>, $& syntax. Output updates as you type.
In-depth guide
JavaScript regex tester with live highlights
Test JavaScript regular expressions against any input string with live match highlighting, numbered and named capture group inspection, and an optional replace preview.
Flags cheat sheet
g — global. Find every match, not just the first.
i — case-insensitive.
m — multiline. ^ and $ match line boundaries instead of only string boundaries.
s — dotall. . matches newlines.
u — unicode mode. Required for \u{...} and \p{...}.
y — sticky. Match must start at lastIndex.
Capture groups, named groups and back-references
Numbered groups — wrap with parentheses: (\w+). Reference in replacement as $1.
Named groups — (?<name>\w+). Reference as $<name>.
Non-capturing — (?:foo|bar). Groups for alternation without producing a capture.
Back-references — \1 in the pattern matches whatever the first group captured.
Common pitfalls
Catastrophic backtracking — nested quantifiers like (a+)+ can hang the engine on long inputs. Prefer non-greedy or atomic alternatives.
Greedy by default — .* matches as much as possible. Use .*? for the lazy version.
Anchors — without ^ / $, a regex matches anywhere. Add them when validating full-string formats.
Escape special chars — . * + ? ( ) [ ] { } | \ ^ $ all need \ when matched literally.
Frequently asked questions
Does this tool send my regex anywhere?
No. Compilation, matching and replacement all run in your browser using the native RegExp engine. No requests fire.
Which regex dialect is supported?
JavaScript's ECMAScript 2018+ regex. Supports lookahead, lookbehind, named groups (?<name>...), unicode property escapes \p{L} with the u flag, and the s (dotall) flag.
How are flags interpreted?
g = find all matches; i = case-insensitive; m = ^ and $ match line breaks; s = dot matches newlines; u = unicode mode (needed for \u{...} and \p{...}); y = sticky.
What replacement variables can I use?
$& for the full match, $1 / $2 / ... for numbered groups, $<name> for named groups, $$ for a literal dollar sign. Same as String.prototype.replace.
Why is the match list truncated?
We cap at 100 displayed rows to keep the UI responsive on huge inputs. The full match count is shown in the header — if you need all entries, narrow your pattern or use the Replace pane.
Why doesn't a regex from another language work?
Perl/PCRE, Python re and .NET each have slightly different syntax — recursive patterns, possessive quantifiers, embedded modifiers. JavaScript supports a slightly narrower set. Test inside JavaScript before relying on it.
Keep exploring
More tools you'll like
Hand-picked utilities that pair well with the one you're on — all
free, client-side, and zero-signup.