Regex Tester

Test JavaScript regex against text with live match highlighting, named and numbered capture groups, a replace preview, a pattern library, and export.

Loading tool…

Regex TesterBuild and debug JavaScript regular expressions with instant feedback: matches are highlighted in the test string as you type, capture groups are listed per match, and all six flags (g, i, m, s, u, y) can be toggled with one click. Zero-length and overlapping edge cases are handled safely, and nothing you test ever leaves your browser. A live replace preview applies a substitution template with $1 and $name backreferences, named capture groups are listed by name beside the numbered ones, a built-in library inserts patterns for email, URL, IPv4/IPv6, ISO dates, phone numbers and hex colors, the whole match list exports as JSON or newline-separated lines, and an optional panel explains each token in your pattern.

What is Regex Tester?

The Regex Tester is a free online regular expression tester and debugger that runs a JavaScript regex pattern against sample text and highlights every match live as you type. Developers, data wranglers, and anyone writing search-and-replace or validation rules use it to build and debug patterns, inspect capture groups, and see how flags change matching. Enter a pattern between the slashes, toggle the g, i, m, s, u, and y flags, paste a test string, and instantly view the match count, highlighted matches, and per-match capture group values. Because it uses the browser-native RegExp engine, results behave exactly as they will in your JavaScript code. Beyond matching it previews a replacement in real time as you type a template with $1 or $name backreferences, shows named capture groups by name alongside the numbered ones, offers a one-click library of common patterns, exports the match list as JSON or plain lines, and can explain the tokens in your pattern in plain language.

How to use Regex Tester

  1. Type your regular expression into the Regular expression field shown between the slash delimiters.
  2. Toggle the flags you need under Flags: g global, i ignore case, m multiline, s dotAll, u unicode, or y sticky; g is on by default. Active flags appear after the closing slash next to your pattern.
  3. Paste or type your sample text into the Test string box, or click Clear to empty it.
  4. Read the Matches count and review the Highlighted panel, where every match is highlighted inline within the test string.
  5. Check the Match details list to see each match's position index, the matched value, and the value of every numbered capture group.
  6. Insert a ready-made expression from the Common patterns menu (email, URL, IPv4, IPv6, ISO date, phone or hex color) when you do not want to write one from scratch.
  7. To rewrite text, type a template into Replace with using $1, $2 or $name backreferences and watch the Replaced text update live.
  8. Copy the Match list as JSON or newline-separated lines, and turn on Explain pattern in the settings to see a plain-language breakdown of each token.

Examples

Find all numbers

Input

pattern \d+ (digit class, flag g) on text a1b22c333

Output

Matches: 3 (highlights 1, 22, 333)

Match a word case-insensitively

Input

pattern Hello (flags i and g) on text hello HELLO Hello

Output

Matches: 3 (highlights hello, HELLO, Hello)

Capture groups from a date

Enter a pattern with three parenthesized digit groups separated by hyphens, such as (\d+)-(\d+)-(\d+), against 2026-06-17 to get one match whose group 1, group 2, and group 3 show 2026, 06, and 17 in Match details.

Reformat a date with named backreferences

Input

pattern (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}), replace with $<d>/$<m>/$<y> on 2026-06-17

Output

Replaced text: 17/06/2026

Frequently asked questions

Which regex flags are supported?
All six JavaScript flags: g (global), i (ignore case), m (multiline), s (dotAll), u (unicode), and y (sticky). Click any flag toggle to switch it on or off; the active flags appear after the closing slash next to your pattern.
What regex syntax does it use?
It uses the browser-native JavaScript RegExp engine, so your pattern behaves exactly as it would in JavaScript or TypeScript code, including capture groups, character classes, lookarounds, and Unicode escapes when the u flag is on.
Why does it say my expression is invalid?
If the pattern cannot be compiled (for example an unbalanced bracket or an unknown escape), the tool shows the exact error message returned by the RegExp constructor instead of any matches. Fix the pattern and the matches update instantly.
Does it show capture groups and match positions?
Yes. Each match is listed in Match details with its starting index in the text, the matched value, and every numbered capture group; empty groups show (empty) and groups that did not participate show a dash.
Is my pattern or test text uploaded anywhere?
No. Everything runs 100% client-side in your browser using the native RegExp engine. Your pattern and test string are never sent to a server, so you can safely test against sensitive or private data.
How do the replace mode and named groups work?
Type a template into Replace with using $1, $2 or $name backreferences (and $& for the whole match); the Replaced text updates live, replacing every match with the g flag on or just the first without it. Groups defined as (?<name>…) are listed by name in each match and can be referenced as $name.
Can I export the matches?
Yes. The match list exports as formatted JSON — each match value, index and capture groups — or as a plain newline-separated list, and both the replaced text and match list can be wired into other workspace tools.

Related tools