Regex Tester

Test regular expressions in real time with live match highlighting, capture group details, and a Replace mode for previewing substitutions.

regex regexp regular expression pattern test match
Free Client-Side Private
/ /
Flags
🔒 This tool runs entirely in your browser — your files are never uploaded to any server.

The Regex Tester is a free, browser-based tool for writing and testing regular expressions in real time. Paste your test string, type a pattern, and matches are highlighted instantly as you type. Switch to Replace mode to preview substitutions with capture group references. All processing runs entirely in your browser — no data leaves your machine.

Features

Feature Detail
Live highlighting Matches highlight instantly as you type — no need to click a button
Test and Replace modes Test mode highlights matches; Replace mode previews the substituted result
Flags panel Toggle g, i, m, s, u flags with checkboxes, or type them directly in the flags field
Capture groups Match table shows each capture group value alongside the full match
Match details table Lists every match with its index, length, and group values
Zero-length match support Matches like ^ or \b are visualised with a cursor marker
Copy result One-click copy of the Replace mode output
Stats bar Live count of total matches, capture group count, and test string length

How to Use

Testing a Pattern

  1. Type your regular expression into the pattern field between the / delimiters.
  2. Optionally type flags (such as gi) in the flags field, or toggle them using the checkboxes.
  3. Paste or type the text you want to test in the Test string area.
  4. Matches are highlighted immediately. Alternating colours help distinguish consecutive matches.
  5. Scroll down to the Match details table to inspect each match's index, length, and capture group values.

Using Replace Mode

  1. Click the Replace tab.
  2. Enter a replacement string in the Replacement string field.
  3. The tool shows a live preview of the full string after applying .replace() with your pattern.
  4. Click Copy to copy the result to your clipboard.

Replacement Syntax

Token Meaning
$& The matched substring
$1, $2, ... Contents of capture group 1, 2, ...
$` The portion of the string before the match
$' The portion of the string after the match
$$ A literal $ character

Regex Flags

Flag Meaning
g Global — find all matches, not just the first
i Ignore case — A matches a
m Multiline — ^ and $ match the start and end of each line
s Dot-all — . matches newline characters as well
u Unicode — enables full Unicode matching and stricter syntax

Common Regex Patterns

Pattern Matches
\d+ One or more digits
\w+ One or more word characters (letters, digits, underscore)
\s+ One or more whitespace characters
^.+$ An entire non-empty line (use m flag for multiline text)
[a-zA-Z]+ One or more ASCII letters
\b\w+\b Complete words
https?://\S+ HTTP or HTTPS URLs
[\w.+-]+@[\w-]+\.[a-z]{2,} Email addresses
(\d{1,3}\.){3}\d{1,3} IPv4 addresses
<[^>]+> HTML tags
`(?:^ \s)#\w+` Hashtags
\d{4}-\d{2}-\d{2} Dates in YYYY-MM-DD format

Capture Groups

Capture groups let you extract specific parts of a match. Wrap a sub-pattern in () to create a group.

  • (\d{4})-(\d{2})-(\d{2}) on 2024-03-15 produces three groups: 2024, 03, 15
  • Named groups use (?<name>...) syntax: (?<year>\d{4}) creates a group named year
  • Non-capturing groups use (?:...) — they group without creating a capture reference

The Match details table shows each group value per match, with - for unmatched optional groups.

Frequently Asked Questions

Why are my matches not highlighted?

Check that you have entered both a pattern and test string. Also verify that the g (global) flag is enabled if you expect multiple matches — without it, only the first match is found. If a regex syntax error is present, the error message appears below the pattern field.

What does the g flag do?

The global flag tells the engine to find all non-overlapping matches in the string. Without it, only the first match is returned regardless of how many times the pattern could match.

Can I use lookaheads and lookbehinds?

Yes. All modern JavaScript regex features are supported, including positive and negative lookahead ((?=...), (?!...)), lookbehind ((?<=...), (?<!...)), and named capture groups. Your browser's built-in RegExp engine powers the matching.

What is the dot-all (s) flag?

By default, . matches any character except a newline (\n). With the s flag enabled, . also matches newline characters, which is useful for patterns that span multiple lines.

How do I match a literal dot or parenthesis?

Escape it with a backslash: \. matches a literal dot, \( matches a literal opening parenthesis.

Is there a limit on matches?

The tester caps display at 10,000 matches to prevent the browser from freezing on very large inputs. The match table shows up to 200 rows. The stats bar always reflects the true count up to the cap.

What does $1 mean in the replacement string?

$1 refers to the first capture group in your pattern. For example, if your pattern is (\w+)\s(\w+) and your replacement is $2 $1, it swaps the two words. Use $& to insert the entire matched text unchanged.

Report an issue