Regex Tester

Write a regular expression and test string to see live-highlighted matches and capture groups as you type.

Test string

2 matches

Contact us at hello@example.com or support@devtools.dev for help.

Example input

\b[\w.-]+@[\w.-]+\.\w+\b

Example output

hello@example.com

What is a Regex Tester?

A regex tester lets you write a regular expression pattern and immediately see, against real sample text, exactly what it matches — highlighted inline, with capture groups broken out separately. This matters because regex is notoriously hard to get right on the first try: a pattern that looks correct can silently match too much, too little, or the wrong part of a string, and the only reliable way to catch that is to test it against real examples rather than reason about it purely in your head.

When to use it

Reach for a regex tester when validating user input (emails, phone numbers, postal codes), extracting a specific piece of data out of log lines or scraped text, writing a find-and-replace pattern before running it against a real codebase, or debugging why a regex in production isn't matching something it should. Testing here first — before pasting a pattern into code — catches mistakes like unescaped special characters or wrong quantifiers without needing to run and re-run your actual program.

How it works

This tool runs your pattern through JavaScript's native RegExp engine — the same engine your pattern will actually run on if you're writing JavaScript or TypeScript — and calls exec() repeatedly to find every match in the test string, highlighting each one and listing out any capture groups (the parts of your pattern wrapped in parentheses). The global (g) flag is automatically applied so every match is found, not just the first one, matching how most real-world regex usage (like String.replace with a global pattern) actually behaves.

Frequently asked questions

Why does my regex work in this tester but not in my code?

The most common cause is flags — check that your code applies the same flags (g, i, m, etc.) shown here. Another common cause is escaping: if your pattern is inside a string literal in your code, backslashes may need to be doubled (e.g., \\d instead of \d) depending on the language.

What do the capture groups shown below the matches mean?

Any part of your pattern wrapped in parentheses — like (\\w+) — becomes a capture group, and its matched text is shown separately for each full match. Capture groups are commonly used to extract specific pieces of data, like pulling the domain out of an email match, or referenced in replacements as $1, $2, and so on.

What's the difference between greedy and lazy quantifiers?

A greedy quantifier like * or + matches as much text as possible before backing off if needed. A lazy quantifier — the same symbol followed by a ? like *? — matches as little as possible instead. This matters most with patterns like <.*> against HTML, where greedy matching can span across multiple tags unintentionally.

Can I use this to test find-and-replace patterns, not just matching?

This tool is focused on match testing and highlighting. For testing an actual find-and-replace with capture group references in the replacement text, this site also has a dedicated Regex Find & Replace tool.