Regex Tester

Type a regular expression to see matches, groups and replacements instantly.

/ /
Flags
Example patterns

Matches highlighted
Match list
#PositionMatchGroups

Everything you enter is processed inside this browser and is never sent to a server.

How to use it

  1. Type a pattern in “Regular expression”. Leave out the surrounding slashes.
  2. Tick the flags you need (g is on by default).
  3. Enter text under “Test string”. Matches are highlighted, and the list below shows each match’s position and capture groups.
  4. Tick “Replace” to preview the result of a replacement.

The tester uses your browser’s JavaScript (ECMAScript) regex engine. Some syntax differs from PCRE, Python or .NET.

Flags

FlagMeaning
gFind all matches, not just the first
iIgnore case
m^ and $ match at the start and end of each line
s. also matches line breaks
uUnicode mode: emoji count as one character and \p{...} works
ySticky: match only from where the last match ended

Common building blocks

SyntaxMeaning
\d, \w, \sDigit, word character, whitespace
[a-z], [^a-z]Character in, or not in, a range
*, +, ?, {2,4}Repeat 0+, 1+, 0–1, or 2–4 times
(...)Capture group, referenced as $1 in replacements
(?<name>...)Named group, referenced as $<name>
(?=...), (?<=...)Lookahead and lookbehind
\p{L}Any letter in any script (needs u)

Safe with heavy patterns

Patterns such as (a+)+$ can take minutes on some inputs because of catastrophic backtracking. This tester runs the regex in a separate thread (a Web Worker) and stops it after 1.5 seconds, so your browser never freezes.

Frequently asked questions

Is my text uploaded?

No. The regex runs entirely in your browser.

Are the example patterns complete validators?

No. They are simplified starting points. Real email address syntax, for example, is far more complex. Adjust them for your use.