Regex Tester

Test a regular expression against your text and see every match, group and replacement.

Runs in your browser

Pattern

//g

Matches: 2

Test text

Preview

Contact admin@example.com or sales@example.com for details.

Match details

#PositionMatchesMatch details
18admin@example.com1=admin2=example
229sales@example.com1=sales2=example

Replace

Everything runs in your browser. Your files are never uploaded.

About this tool

Write a pattern, paste the text it should match, and see the results live: every match highlighted in place, a table of capture groups with their positions, and the outcome of a replacement string. Flags are toggles, syntax errors are reported as you type, and nothing is sent anywhere.

How to use it

  1. 1Type your pattern and switch on the flags you need.
  2. 2Paste the text to test — matches highlight immediately.
  3. 3Check the group table, then try a replacement string to see the rewritten result.

Frequently asked questions

Why does an empty match not hang the page?

A pattern like a* matches the empty string at every position, and the obvious loop over matches never advances, so a careless tester locks the browser up. This one detects a zero-length match and steps forward one character before continuing, and it stops after 5,000 matches.

What do the g and y flags have to do with each other?

Both control where the next search starts, and switching both on produces behaviour that surprises almost everyone. This tool makes them mutually exclusive — turning one on turns the other off — so the result always matches what you expect from reading the flag bar.

Why is my pattern rejected before I finish typing?

Because the pattern is compiled on every keystroke, an unfinished group like (abc shows a syntax error immediately. That is intended: the error text is the one your browser actually produces, which is usually more precise than a generic explanation.

Related tools

Browse all tools