Regex Tester

Test a regular expression against your own text. Matches are highlighted as you type, with every capture group, its position, and a live replace preview.

Updated
Runs in your browser. Your data is not uploaded.
Flags
Highlighted matches

    
Matches
#MatchStartEndGroups
Uses your browser's JavaScript regex engine.

How to use the Regex Tester

  1. Type your expression into Regular expression, without the surrounding slashes, and tick the Flags you need.
  2. Paste the text to search into Test string. Matches are highlighted right away.
  3. Read the Matches list for each match's position and groups. To try a substitution, fill in Replace with and check the result below it.

How it works

The tester uses the JavaScript regular expression engine built into your browser, the same one used by String.prototype.matchAll and replace.

  • With the g flag every match is listed. Without it, only the first match is.
  • Positions are zero-based character offsets. The end index is exclusive, so a match from 0 to 4 covers four characters.
  • Empty matches, for example from a*, are counted but not highlighted.
  • In the replacement, $1 inserts group 1, $<year> inserts a named group, $& inserts the whole match, and $$ inserts a dollar sign.

Examples

  • (\d{4})-(\d{2})-(\d{2}) with flag g on Released 2026-09-26, patched 2026-10-02 finds 2 matches. The first is 2026-09-26 at index 9 to 19, with groups 2026, 09, and 26.
  • Replacing the same pattern with $3/$2/$1 gives Released 26/09/2026, patched 02/10/2026.
  • ^\s+|\s+$ with flag g matches leading and trailing spaces, the same thing trim() removes.
  • (?<user>[\w.]+)@(?<domain>[\w.-]+) on [email protected] gives the named groups user = ada and domain = example.com.

Regex flags

FlagNameEffect
gGlobalFind every match, not just the first
iIgnore casea also matches A
mMultiline^ and $ match at each line break
sDot all. also matches line breaks
uUnicodeTreats emoji and other astral characters as one character and enables \p{...}
yStickyEach match must start exactly where the last one ended

Limitations

  • The syntax is JavaScript's. PCRE features such as possessive quantifiers (a++), atomic groups, recursion, and \A or \Z are not supported. Lookbehind works in all current browsers.
  • A badly written pattern can take very long on some inputs (catastrophic backtracking). The tester stops listing after 5,000 matches, but it can't interrupt a single slow match.
  • Your text isn't changed. The replace preview shows what replace would return.

Frequently asked questions

Which regex flavor does this tester use?

JavaScript (ECMAScript), as implemented by your browser. Most everyday syntax is shared with PHP, Python, and Java, but some advanced features differ.

Why does my pattern only find one match?

Tick the g (global) flag. Without it, a regular expression stops after the first match.

How do I match a literal dot or bracket?

Escape it with a backslash: \., \(, \[. Without the backslash, a dot matches any character.

Do I need to escape forward slashes?

No. Type the pattern without the surrounding /.../, and slashes inside it need no escaping.

Is my test text uploaded?

No. Matching runs in your browser, and nothing you type is sent anywhere.

Often used together with the Regex Tester.

  • Sed Command Generator

    Builds sed commands for substitution, deletion, printing, and inserts, with a live preview.

  • Diff Checker

    Compares two texts or code files and highlights added, removed, and changed lines.