ZYBERMART

Regex Tester

Test regular expressions with live match highlighting, capture groups, flags and a replace preview.

/ / g

#MatchIndexGroups

Regex cheat sheet

PatternMatches
.Any character except a newline
\d \w \sDigit, word character (letter, digit, _), whitespace
[abc] [^abc] [a-z]One of a, b or c; anything but them; a range
* + ?0 or more, 1 or more, 0 or 1 (add ? to make lazy)
{2} {2,} {2,5}Exactly 2, at least 2, between 2 and 5
^ $ \bStart of text/line, end of text/line, word boundary
(…) (?:…) (?<name>…)Capture group, non-capturing group, named group
a|ba or b
(?=…) (?!…) (?<=…)Lookahead, negative lookahead, lookbehind

Useful patterns

  • Email address (simple): [\w.+-]+@[\w-]+\.[\w.-]+
  • URL: https?:\/\/[^\s]+
  • Date YYYY-MM-DD: \d{4}-\d{2}-\d{2}
  • Hex color: #(?:[0-9a-fA-F]{3}){1,2}\b
  • Extra spaces: {2,} (replace with one space)

Frequently asked questions

Which regex flavor does this tester use?

It uses JavaScript (ECMAScript) regular expressions, the same engine as your browser and Node.js. Most syntax is shared with Python, Java, C# and PCRE, but features such as lookbehind, named groups and Unicode classes can differ slightly between languages.

What do the flags mean?

g finds all matches instead of just the first, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode support, and y (sticky) only matches at the current position.

How do I use capture groups in the replacement?

Use $1, $2 and so on for numbered groups, $<name> for named groups, and $& for the whole match. For example, replacing (\w+)@(\w+) with $2 at $1 swaps the two parts.

Why does my pattern stop with “took too long”?

Some patterns, especially nested quantifiers like (a+)+, can take exponential time on certain input. The tester runs your regex in a background worker and stops it after a second, so the page never freezes. Simplify the pattern to fix it.