Regex Tester

Write a regular expression and see every match highlighted as you type, with capture groups, flags and a live replace preview.

//g
Flags
Common patterns
Test string
Matches highlighted
Replace result

How to test a regular expression

  1. Type your pattern between the slashes and choose the flags you need.
  2. Paste or type your test string. Every match is highlighted instantly, and each match lists its position and capture groups.
  3. Use the Replace box to preview a substitution with $1, $2, $& or named groups.

Features

Live highlighting

Matches update on every keystroke.

Capture groups

Numbered and named groups for every match.

Replace preview

Test substitutions before using them in code.

Private

Everything runs in your browser; nothing you paste is uploaded.

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript) regular expressions, the engine built into your browser. Lookbehind, named groups and Unicode property escapes are supported in modern browsers. Syntax for PCRE, Python or Java is very similar but not identical.

What do the flags mean?

g finds all matches instead of the first, i ignores case, m makes ^ and $ match at each line, s lets the dot match newlines and u enables full Unicode matching.

How do I use capture groups in the replacement?

Wrap part of the pattern in parentheses, then refer to it as $1, $2 and so on. $& inserts the whole match, and $ inserts a named group written as (?…).

Why is my regex slow or freezing the page?

Patterns with nested quantifiers such as (a+)+ can backtrack catastrophically on some input. Simplify the pattern or make it more specific.