Regex Tester

Text & Developer

Regex Tester

The regex tester lets you write a JavaScript regular expression and see every match highlighted in your sample text as you type. Toggle the flags, inspect capture groups with their positions, and preview a find-and-replace result. It all runs in your browser.

  • Live highlighting
  • Capture groups
  • Replace preview
  • JavaScript flavour
//

Regex quick reference

TokenMeaning
.Any character except a line break (with s, including line breaks)
\d \w \sDigit, word character, whitespace
^ $Start and end of the string (or line with m)
* + ?Zero or more, one or more, optional
{2,4}Between 2 and 4 repeats
( )Capture group
(?: )Non-capturing group
[a-z]Any character in the set
a|bEither a or b

Flags

  • g finds all matches instead of the first.
  • i ignores upper and lower case.
  • m makes ^ and $ match at each line.
  • s lets the dot match line breaks.
  • u turns on full Unicode support.
This tester uses the JavaScript regular expression engine in your browser. Other languages such as PCRE, Python or Java differ in small ways, for example in lookbehind and named group syntax.

Questions people ask

Why does my regex hang?

Patterns with nested repeats such as (a+)+ can take exponential time on some inputs. Simplify the pattern or anchor it.

How do I match a literal dot?

Escape it with a backslash: \. matches an actual period.

How do I use groups in the replacement?

Use $1, $2 and so on for numbered groups and $& for the whole match.

Related tools

Scroll to Top