Advertisement

Regex tester

Test regular expressions with live match highlighting, match counts and a replace preview.

Pattern

JavaScript regex flavor. Updates live.

Use $1, $2 for groups, $& for the whole match, $$ for a literal $.
Matches
0

Matches update live as you type.

Private by design: matching runs locally in JavaScript. There is no server, no account and no tracking of what you test.
Advertisement

Quick cheatsheet

.Any character except newline (or any with s flag)
\d \w \sDigit, word char, whitespace
\D \W \SNot a digit, not a word char, not whitespace
^ $Start / end of string (or line with m flag)
* + ?0 or more, 1 or more, 0 or 1
{n} {n,} {n,m}Exactly n, n or more, between n and m
( ) (?: )Capture group, non-capture group
[abc] [^abc]One of these, none of these
a|ba or b
\bWord boundary
(?= ) (?!) Lookahead, negative lookahead

Flags explained

  • g (global): find every match, not just the first.
  • i (ignore case): A matches a.
  • m (multiline): ^ and $ match the start and end of each line.
  • s (dotAll): the dot also matches newlines.
  • u (unicode): full Unicode matching, needed for \p{...} classes.

Regex tester FAQs

Which regex flavor does this tester use?
JavaScript. The pattern runs in your browser with the same engine as Node.js and modern browsers, so what you see here matches what your code will do.
What do the g, i, m, s and u flags mean?
g finds all matches instead of stopping at the first. i ignores case. m makes ^ and $ match line starts and ends. s lets the dot match newlines. u enables full Unicode mode.
Why does my regex show an "Invalid regular expression" error?
Usually a typo: an unclosed bracket or parenthesis, a stray backslash, or a quantifier like * or + with nothing in front of it. The error message names the exact problem.
Is my test data uploaded anywhere?
No. Matching happens entirely in your browser with JavaScript. Your text never leaves your device.
How do I use the replace preview?
Type a replacement string and the preview shows the result live. Use $1, $2 and so on to insert capture groups, $& for the whole match, and $$ for a literal dollar sign.
Advertisement