Regex Tester
Regex Tester — write and test JavaScript regex patterns. See live highlights, capture groups, and replacement previews. Free, no signup.
Type a replacement to preview
About Regex Tester
Regex Tester is a fast, browser-only environment for writing and validating JavaScript regular expressions. Type a pattern in the top input, paste your test text below, and the tool runs the regex on every keystroke — highlighting every match, listing capture groups by index and name, and previewing the result of a replace operation alongside.
This is JavaScript’s regex engine — the same one used by your browser, Node.js, and almost every JS-based linter, parser, or build tool. So if a pattern works here, it works in your app. If it fails here, it’ll fail there too, and the exact error message tells you why.
When to reach for this
The common cases: you’re writing a String.prototype.replace call and the regex isn’t doing what you expect, you’re debugging why a validation regex accepts something it shouldn’t (or rejects something it should), you’re translating a regex from one language to another and want to confirm the JavaScript version works, or you’re learning regex and want a fast feedback loop without rerunning a script each time.
The replace preview is particularly useful for confirming substitution behaviour — $1, $&, named group references — before pasting the regex into production code where a wrong replacement does real damage.
Capture groups, numbered and named
Every match displays its capture groups below the match text. For a pattern like (\\w+)@(\\w+\\.\\w+), you’ll see $1 (the username) and $2 (the domain) under each match. For named groups like (?<user>\\w+)@(?<domain>\\w+\\.\\w+), the named keys appear alongside the numbered ones. Groups that didn’t participate in a match (e.g. one side of an unmatched (a|b)) are skipped.
Flags, in plain language
- g — global, find all matches not just the first
- i — ignore case
- m — multiline mode for
^and$ - s — dotall mode (
.matches newlines) - u — full unicode support
- y — sticky mode (match must start at
lastIndex)
The most common combination is g + i for “find all matches, case-insensitive.” For multiline blocks of text where you want . to match line breaks, add s. For matching emoji or other multi-codepoint characters, enable u.
Replace syntax cheatsheet
The Replace input supports the full JavaScript replacement string syntax:
$1-$9— numbered capture group$<name>— named capture group$&— the entire matched substring$`— everything before the match$'— everything after the match$$— a literal$
Free, runs in your browser, no signup, no ads.
Frequently asked questions
JavaScript / ECMAScript regex — the same engine used by V8 (Chrome, Node.js), JavaScriptCore (Safari), and SpiderMonkey (Firefox). It supports all the modern JS features: named groups (`(?<name>...)`), lookbehind (`(?<=...)`), unicode flag (`/u`), sticky flag (`/y`), and dotall (`/s`). If you're writing regex for a JavaScript app, this is the right tester.
Six flags: `g` (global — find all matches, not just the first), `i` (case-insensitive), `m` (multiline — `^` and `$` match line boundaries), `s` (dotall — `.` matches newlines), `u` (full unicode support, enables `\u{...}` escapes), `y` (sticky — match must start at lastIndex). Toggle the boxes above the pattern to switch them on or off.
Every match shows its groups in the match list below the highlighted text. Numbered groups show as `$1`, `$2`, etc. Named groups (`(?<email>...)`) show with the name as the key. If a group didn't participate in a match (e.g. inside an OR that didn't match its branch), it's skipped.
Yes — the Replace section previews the result of running `text.replace(pattern, replacement)` live. Replacement supports the full JavaScript replace syntax: `$1`-`$9` for capture groups, `$&` for the entire match, `$\`` for everything before the match, `$'` for everything after, and `$$` for a literal dollar sign.