🔍 Regex Tester

JavaScript RegExp against a test string — live matches, flags, groups, presets.

Free Instant results No sign-up needed
regex

Regex Tester

Build, test, and debug regular expressions live in your browser — with match highlighting and capture groups.

Live Client-side Highlighting
Match preview
Character classes
.Any character except newline
\dDigit [0–9]
\DNon-digit
\wWord [a-zA-Z0-9_]
\WNon-word
\sWhitespace
\SNon-whitespace
[abc]Character set
[^abc]Negated set
[a-z]Range
Quantifiers
*0 or more (greedy)
+1 or more (greedy)
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m
+?1 or more (lazy)
*?0 or more (lazy)
Anchors & boundaries
^Start of string/line
$End of string/line
\bWord boundary
\BNon-word boundary
Groups
(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
a|bAlternation (a or b)
\1Backreference to group 1
Escapes
\nNewline
\tTab
\rCarriage return
\\Literal backslash
Flags (click to toggle)
gGlobal — all matches
iCase insensitive
mMultiline (^/$)
sDot matches newline
uUnicode mode

This page compiles a JavaScript RegExp from the pattern field and runs it against the test string in your browser. Matches are highlighted, numbered, and listed with start index, length, numbered groups ($1…), and named groups when the pattern uses (?<name>…).

The engine you are actually testing

Results follow ECMAScript regular expressions, the same dialect as new RegExp(pattern, flags) in Chrome, Firefox, Safari, and Edge. Lookaheads, named groups, and Unicode property escapes (with the u flag) behave as they would in front-end JavaScript.

They will not match PCRE, Python re, or POSIX EREs. Tokens such as possessive quantifiers, \A/\Z, or (?i) inline flags are syntax errors here. If a pattern will live in PHP or Python, this tester is a rehearsal for the JavaScript subset only.

Flags on this page

There is no sticky y flag. The highlighter internally walks with RegExp.exec and stops after 5,000 hits so a pattern like a* cannot freeze the tab. Match cards stop at 50; remaining hits still count in the status line.

  • g — global. Copy Pattern includes this flag so your own String.prototype.match returns every hit, not only the first.
  • i — ignore ASCII letter case.
  • m — ^ and $ also match line boundaries, not only the start and end of the whole string.
  • s — dot-all, so . matches newline.
  • u — Unicode mode (required for \p{…} and astral characters).

Running a test

  1. Type a pattern between the slash delimiters (the slashes are decoration, not part of the pattern).
  2. Paste sample text in Test String.
  3. Toggle flags on the right of the pattern field.
  4. Wait ~220ms for the live run, or click Test / press Ctrl+Enter.
  5. Use Presets for starter patterns, the cheatsheet to insert tokens, Copy for /pattern/flags, and Clear to reset both fields.

A small original example

Pattern (?<id>NX-\d{4}) with flag g against the string Ticket NX-1042 closed; NX-2210 still open should produce two matches, each exposing named group id. If you forget to escape the hyphen inside a character class, or write \d{4 without the closing brace, the status line shows the engine’s syntax error instead of empty matches.

Input → matches

Pattern
(?<id>NX-\d{4})
Test string
Ticket NX-1042 closed; NX-2210 still open
What you should see
2 matches
$1 / named id: NX-1042 at index 7
$1 / named id: NX-2210 at index 29

Mistakes this UI makes obvious

  • Double-escaping: in this box write \d, not the extra backslashes you need inside a JavaScript string literal.
  • Greedy .* swallowing too much; try .*? or a negated class.
  • Anchors that fail because the sample has a trailing newline and m is off.
  • Zero-length matches (empty groups). The runner advances lastIndex by one to avoid an infinite loop.

Where the text stays

Pattern and sample never leave the tab. Theme preference is stored in sessionStorage under a lab key. No regex is compiled on our servers.

JavaScript regex questions

Which regex dialect is this?

The browser’s JavaScript RegExp engine. Possessive quantifiers, \A, and inline (?i) flags from PCRE will error here.

Why do I still see many matches with g off?

The highlighter walks with exec and may list many hits (up to 5,000, 50 cards). Turn g on when you copy /pattern/flags so your own match() returns every hit.

Is there a sticky y flag?

No. Only g, i, m, s, and u are toggles.

Does the pattern leave my browser?

No. It is compiled in this tab.

How do I insert a starter pattern?

Open Presets (email, URL, IPv4, and others) or the cheatsheet tokens, then edit.

After the pattern works

Use Text Compare to diff two log excerpts, or JSON Formatter if the capture is a payload: Text Compare, JSON Formatter, URL Encoder / Decoder. Browse the full Developer set or the all tools hub.