Toolbench

Regex tester

Type a pattern and some text to see every match highlighted, each capture group in a table, and a live replace preview.

Runs entirely in your browser. Nothing you type, paste or open here is uploaded to any server.

How do I test a regular expression?

Run the pattern against sample text that includes cases it should match and cases it should not, then check each match and capture group. Type both here and the matches update as you type.

  1. Type the pattern without the surrounding slashes.
  2. Tick flags: g for all matches, i to ignore case, m for line anchors, s so dot matches newlines.
  3. Paste test text with good and bad examples.
  4. Check highlights and the groups table.
  5. Try a replacement using $1, $2 for groups.

Examples

Pull the domain from emails

Input

Pattern: (\w+)@([\w.-]+\.\w+)
Text: Contact jane@acme.com

Result

Match: jane@acme.com
Group 1: jane
Group 2: acme.com

Reformat dates

Input

Pattern: (\d{4})-(\d{2})-(\d{2})
Replace: $2/$3/$1
Text: 2026-11-09

Result

11/09/2026

Frequently asked questions

Which regex flavor is this?

JavaScript (ECMAScript), as run by your browser. Most syntax is shared with Python, PHP and Java, but lookbehind support and named group syntax can differ.

Why does my pattern only find one match?

Turn on the g flag. Without it, a regex stops after the first match.

How do I match a literal dot or bracket?

Escape it with a backslash, like \. or \[.

Can a bad regex freeze the page?

Some patterns with nested repeats take a very long time on certain text. The tool stops after 5,000 matches, but rewrite patterns like (a+)+ if the page slows down.

Related news

Related tools