Regex Tester

Test JavaScript regular expressions with live match highlighting, group inspection, and replace preview.

/ /

  
Common Patterns

Features

Real-time highlighting
Flag support (g, i, m, s)
Match group info
Common patterns reference
Replace function

How to Use

1. Type your regex pattern in the top box.

2. Pick flags (g, i, m, s).

3. Type test text below — matches are highlighted live.

4. Switch to the Replace tab to preview replacements.

About this tool

Regular expressions are powerful and famously easy to get subtly wrong. This tester runs your pattern with JavaScript's own regex engine — the same one used in browsers and Node.js — and highlights every match in the test text as you type. The match details list each match with its position and the value of every capture group, and the replace panel previews substitutions using $1, $2 and other group references. Flags are one click away: g finds all matches, i ignores case, m makes ^ and $ work per line, and s lets the dot match line breaks. A short library of common patterns for email addresses, URLs, phone numbers, dates, hex colours and IPv4 addresses gives you a starting point to adapt.

Frequently Asked Questions

Which regex flavour does this tester use?
JavaScript (ECMAScript). Most syntax is shared with PCRE, Python and Java, but some features differ, for example possessive quantifiers and certain lookbehind or named-group syntax. Test in your target language if the pattern will run elsewhere.
What do the g, i, m and s flags do?
g returns all matches instead of the first, i makes matching case-insensitive, m makes ^ and $ match at the start and end of each line, and s allows . to match newline characters.
How do capture groups and $1 work in replacements?
Parentheses capture the text they match. In the replacement, $1 inserts the first group, $2 the second, and $& the whole match. For example, (\w+)@(\w+) replaced with $2 at $1 turns user@example into example at user.
Why does my pattern match too much?
Quantifiers like .* and .+ are greedy and take as much text as possible. Add ? to make them lazy (.*?), or use a more specific character class such as [^"]* to stop at the right place.
Is it safe to use regex to validate email addresses?
A regex can catch obvious typos, but fully valid email syntax is too complex for a practical pattern. Use a simple check and confirm the address by sending a verification email.

Related Tools