Regex Tester with Live Match Highlighting

Write a pattern, paste some sample text, and watch matches light up as you type. Ideal for building validation rules, log filters and search-and-replace expressions without a compile–run–check loop.

How the tester works

The tool uses your browser's native JavaScript RegExp engine, so results match exactly what you will get in Node.js, Deno or front-end code. Each match in the test string is highlighted, and the match list below shows the full match, its index and every capture group as a numbered entry (Group 1, Group 2…), so you can confirm you are extracting the right piece. Named groups work in the pattern but are listed by number, not by name.

Syntax errors (an unclosed bracket, a dangling quantifier) are reported as an "Invalid regex" message instead of silently matching nothing.

Understanding the flags

g (global) finds all matches instead of stopping at the first. i makes the pattern case-insensitive. m (multiline) makes ^ and $ match at line boundaries rather than only at the start and end of the whole string. s (dotAll) lets . match newline characters, which matters when you are matching across lines in logs or HTML.

Tips for writing better patterns

Prefer specific character classes (\d, [A-Za-z]) over .* to avoid catastrophic backtracking. Use non-capturing groups (?:…) when you need grouping but not extraction. Named groups (?<year>\d{4}) make the result self-documenting. Anchor validation patterns with ^ and $ so abc@example.com is accepted but junk abc@example.com junk is not.

How to use it

  1. Type a pattern in the Pattern field (without surrounding slashes).
  2. Type the flags you need into the Flags field (it starts as gi). Without g, only the first match is highlighted.
  3. Paste representative test data, including a few lines that should not match, and check the highlights and group values.

Example: extracting dates from a log line

Pattern:

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

Against the text 2026-11-07 ERROR disk full; retry at 2026-11-08 with the g flag, you get two matches, each listing Group 1, Group 2 and Group 3 (year, month and day) filled in. Replace \d{2} with (0[1-9]|1[0-2]) on the month to reject impossible values like 13.

Common use cases

Quirks of this tester

The match list always runs with the global flag even if you leave g out of the Flags field, so every match is listed (up to the first 30), but without g only the first match is highlighted in the text. Groups appear as numbered entries (“Group 1”), and a group that did not take part in the match is shown as undefined. The tester needs both a pattern and some text before it shows any results.

Be careful with patterns that can match an empty string, such as x* or (a|b)*, when g is on: the highlighter can end up looping and freezing the browser tab. Prefer x+, or add an anchor so that a match must contain something.

Replacement strings

Once the pattern is right, in JavaScript you can replace using $1, $2 and so on. For example (\d+)-(\d+)-(\d+) with the replacement $3/$2/$1 turns 2026-11-07 into 07/11/2026. This tester shows matches only; run the replace in your own code.

Frequently asked questions

Which regex flavour does this tool use?

JavaScript (ECMAScript). Most syntax is shared with PCRE, Python and Java, but lookbehind support, possessive quantifiers and some Unicode features differ between engines, so test in your target language for edge cases.

Why does my pattern only highlight the first match?

The Flags field does not contain g, so only the first match is highlighted (the match list below still shows all matches, up to 30).

How do I match a literal dot, plus sign or bracket?

Escape it with a backslash: \. \+ \[ and so on. Inside a character class most metacharacters lose their special meaning, so [.] also matches a literal dot.

Is the text I paste sent anywhere?

No. Matching runs in your browser; the tool has no server component.

Why is only the first match highlighted?

Because the Flags field does not contain g. The match list still shows all matches.

Related tools

Explore all developer tools →