Skip to main content

Regex Tester

Regex Tester runs your pattern with the browser's own JavaScript regular expression engine — the same RegExp behaviour you get in Node or a browser console, not PCRE, Python, Java, or .NET.

JavaScript regular expressions

Flags

JavaScript syntax: $& whole match, $1 group 1, $<name> named group, $$ literal $. Without the g flag only the first match is replaced.

Cheatsheet

Character classes

.
Any character except newline (all characters with the s flag)
\d
Digit 0-9
\D
Non-digit
\w
Word character: letter, digit or underscore
\s
Whitespace (space, tab, newline…)
[abc]
One of a, b or c
[^abc]
Any character except a, b or c
[a-z]
Range: any lowercase letter

Quantifiers

*
0 or more
+
1 or more
?
0 or 1 (optional)
{n}
Exactly n times
{n,}
n or more times
{n,m}
Between n and m times
*? +? ??
Lazy: match as few as possible

Anchors & boundaries

^
Start of string (start of line with the m flag)
$
End of string (end of line with the m flag)
\b
Word boundary
\B
Not a word boundary

Groups & references

(…)
Capturing group, numbered from 1
(?:…)
Non-capturing group
(?<name>…)
Named capturing group
\1
Backreference to group 1
\k<name>
Backreference to a named group
a|b
Alternation: a or b

Lookaround

(?=…)
Lookahead: followed by
(?!…)
Negative lookahead: not followed by
(?<=…)
Lookbehind: preceded by
(?<!…)
Negative lookbehind: not preceded by

Escaping

\.
A literal dot (escape . * + ? ( ) [ ] { } ^ $ | \ /)
\\
A literal backslash
\uXXXX
Unicode code unit; \u{XXXX} with the u flag
Processed locally in your browser

How to use it

  1. Enter your regular expression in the Pattern field and tick the flags you need
  2. Paste or type the text to run it against in Test text
  3. Select Test regex to see the match count, highlighted matches, and every capture group
  4. Add a replacement to preview substitutions, then copy the matches or the replaced text

Enter a pattern, pick the flags you need (g, i, m, s, u, y, and d for match indices), and paste the text to test against. It reports how many matches were found and how many capture groups the pattern declares, then lists every match with its start and end position, its numbered groups, and any named groups such as (?<year>\d{4}); a group that did not participate is shown as undefined rather than an empty string. The test text is redrawn with each match highlighted and numbered, so overlaps and zero-length matches stay visible. A replacement field applies JavaScript's native syntax — $&, $1, $<name>, $$ — and without the g flag only the first match is replaced. Each run executes in a dedicated Web Worker: long-running expressions are stopped after one second and the worker is discarded, which limits page freezes without being a guarantee against every pathological pattern. Beyond a yes/no match check it surfaces every group, previews replacements, and highlights results inline; a compact cheatsheet covers the common tokens. Everything runs in your browser and nothing you paste is uploaded.

FAQ

We use cookies to run this site and, with your consent, to understand usage and personalize ads. You can change your choice at any time.