Regex Tester

Write a pattern, paste a test string, and see every match, its capture groups and the replaced result as you type.

Runs in your browser — nothing is uploaded

2 matches

Contact dana@tooljson.com or sam@example.com for access.
  1. index 8dana@tooljson.com
    • $1: dana
    • $2: tooljson
  2. index 29sam@example.com
    • $1: sam
    • $2: example
Replaced text

Matching uses your browser’s JavaScript regular expression engine. Patterns with nested quantifiers can run slowly on long input because the engine backtracks in the page.

About the Regex Tester

A regular expression describes a pattern of text. Developers use them for validation, log parsing, search and replace, and data extraction, but a small mistake such as a missing escape or a greedy quantifier can silently match the wrong text. Testing the pattern against real samples catches those errors before the code ships.

This tester uses the JavaScript RegExp engine that your browser runs, so the results match what Node.js and browser code will do with the same flags. Each match is highlighted in the text, its index is listed, and numbered groups show what each parenthesis captured.

The Global flag controls whether the tester looks for every match or only the first. Ignore case, Multiline and Dot-matches-newline change how ^, $, . and letter case behave. Replacement supports $1-style references to capture groups.

FAQ

Regex Tester — frequently asked

What does the g flag do?

Without g, a regex stops at the first match. With g, it continues through the whole string and returns every match, and replace() substitutes all of them. Forgetting g is a common reason a validator only checks the start of a value.

Why does my pattern match in the tester but not in my code?

The usual causes are different flags, a missing escape when the pattern lives inside a string literal (for example \\d becomes \d only once), or a different regex dialect. Python, Java and PCRE support features such as lookbehind and possessive quantifiers differently from JavaScript, so check the dialect your runtime uses.

How do capture groups work?

Each parenthesis captures the text it matches and numbers the groups from left to right, starting at 1. In a replacement, $1 inserts the first group, $2 the second, and $& the whole match. Use (?:...) for a group you do not need to capture.

What is catastrophic backtracking?

It happens when nested quantifiers such as (a+)+ try exponentially many ways to split the input before failing. A short string can freeze the page. Rewrite the pattern with possessive-style logic, anchor it, or limit the repetition, and test with a long non-matching string.

Does the m flag change ^ and $?

Yes. Without m, ^ and $ match only the start and end of the whole string. With m, they also match at the start and end of each line, which is useful when you validate lines in a log or a config file.

Is my test string sent to a server?

No. The pattern is compiled and run with JavaScript in your browser. The page does not send either field to a server, so you can test patterns against sensitive log lines.

    Report an issue