Regex Tester

Test a regular expression against sample text live β€” matches highlight as you type, with full capture-group detail below.

/ /
g globali case-insensitivem multilines dotAllu unicode

How to use it

  1. Type your pattern between the slashes β€” no need to escape the outer slashes themselves.
  2. Set flags in the second box: g to find all matches, i for case-insensitive, m for multiline anchors, s for dotAll, u for Unicode mode.
  3. Paste or type your test string. Matches highlight live as you edit either field.
  4. Scroll down to see each match listed individually with its index, full match text, and any capture groups.

What's actually happening

This tool builds a real JavaScript RegExp object from your pattern and flags β€” new RegExp(pattern, flags) β€” and runs it against your test string with matchAll() when the g flag is set, or match() otherwise. Every match, its index within the string, and its capture groups (both numbered and named) come directly from what the regex engine returns, so behavior matches exactly what you'd see running the same pattern in your own code.

Highlighting works by walking through matches in order and wrapping each matched substring in a <mark> element, with the surrounding text properly escaped so the highlight can't be broken by special characters in your test string.

Worked example

Extracting capitalized words with \b[A-Z][a-z]+\b and the g flag against "Ada Lovelace wrote notes...":

Matches found
Ada
Lovelace
Analytical
Engine
Grace
Hopper
Why "wrote" doesn't match
Pattern requires an
uppercase first letter.
"wrote" is lowercase,
so [A-Z] fails at
position 0 of the word.

Reference: common patterns

PatternMatches
\d+One or more digits
\w+@\w+\.\w+A simple (non-exhaustive) email shape
^https?:\/\//A string starting with http:// or https://
(\d{4})-(\d{2})-(\d{2})An ISO date, with year/month/day captured
\s+One or more whitespace characters
(?<year>\d{4})A 4-digit year captured under the name "year"

Frequently asked questions

Why do I only see one match without the "g" flag?

Without the global "g" flag, JavaScript's regex engine stops after the first match β€” that's the language's default behavior. Enable "g" to find every match in the text instead of just the first one.

What's the difference between the "i", "m", "s", and "u" flags?

"i" makes matching case-insensitive. "m" makes "^" and "$" match the start/end of each line. "s" (dotAll) makes "." match newlines too. "u" enables full Unicode mode, affecting character classes and escapes.

Why does my pattern throw a SyntaxError?

Usually an unescaped special character used where the engine expects something else β€” an unmatched parenthesis or bracket, an invalid quantifier, or a backreference to a nonexistent group. This tool shows the exact JavaScript engine error.

What are numbered capture groups?

Parentheses in a pattern β€” like (\d+) β€” create a capture group, and the text they match is extracted separately. Groups are numbered left to right starting at 1. This tool lists each match's captured groups alongside the full match.

Can I test named capture groups?

Yes. Patterns like (?<year>\d{4}) work exactly as in your own JavaScript code, and this tool displays named groups by name alongside the numbered ones.

About this tool

This tester uses JavaScript's native regex engine (ECMA-262), the same one your browser and Node.js use β€” not a simulated or simplified matcher. That means results here match your actual runtime exactly, including edge cases around lookaheads, lookbehinds, and Unicode property escapes when the u flag is set.

Related tools