The Magic Codex

Regex Tester

Type a regular expression, toggle the flags, and test it against your own text — matches highlight live, with groups and indices listed.

Just the pattern — no leading/trailing slashes. Everything stays in your browser.

Regex cheat sheet

The tokens you'll reach for most — keep this tab open while you build your pattern.

PatternMeansExample
.Any character except newlinea.c matches "abc"
\dDigit (0–9)\d+ matches "42"
\wWord character (letters, digits, _)\w+ matches "hello"
\sWhitespace\s+ matches spaces
* + ?Zero or more / one or more / optionalab? matches "a" or "ab"
{n,m}Between n and m times\d{3,4} matches "1234"
^ $Start / end of string (of each line with m)^Hi matches "Hi there"
[abc] [^abc]Any of / none of these characters[aeiou] matches "a"
(...)Capture group(\d+)-(\d+) captures "2026-10"
(?:...)Non-capturing group(?:ab)+ matches "abab"
|Either / orcat|dog matches "dog"
\bWord boundary\bcat\b matches "cat", not "cats"
\Escape a special character\. matches a literal dot
g i m s uFlags: global, ignore case, multiline, dot-all, unicode/abc/i matches "ABC"

How to test a regular expression

Regular expressions are powerful but unforgiving — one misplaced parenthesis and nothing matches. A regex tester closes the feedback loop: you write the pattern, paste real sample text, and instantly see what the engine actually matches, character by character.

  1. Type your pattern in the box above — no slashes needed, just the expression itself.
  2. Pick your flags. g finds every match (not just the first), i ignores case, m makes ^ and $ work per line, s lets the dot match newlines, and u enables unicode mode.
  3. Paste test text — the real data your pattern will face, including the edge cases.
  4. Read the matches. Each match is highlighted in the text and listed with its index and captured groups, so you can verify the groups feed your code correctly.

Start small, then grow the pattern

The fastest way to build a tricky expression is one token at a time: get \d+ matching numbers first, then wrap it in a group, then add the surrounding context. When a change breaks everything, the red error box tells you exactly which part of the pattern the engine rejected.

What is a regex tester?

A regex tester lets you try out a regular expression against sample text and instantly see which parts match, including captured groups and match positions.

How do I test a regex pattern with the flags?

Type your pattern, tick the flags you need (g for global, i to ignore case, m for multiline, s so the dot matches newlines, u for unicode), paste sample text, and every match is highlighted with its index and captured groups listed.

Why is my regular expression not matching?

Common culprits: forgetting the g flag (so only the first match shows), special characters that need escaping (like the dot or parentheses), or anchors like ^ and $ that need the m flag for multiline text. This regular expression tester online shows exactly what the engine sees.

What do the captured groups mean?

Parentheses in your pattern capture the text they match. For example, (\d+)-(\d+) on 2026-10-03 captures 2026 as group 1 and 10 as group 2.

Is my pattern or test text sent anywhere?

No — your browser's built-in regular expression engine does all the work on your own device. Nothing is uploaded or stored.

What does the error message mean?

The red box shows the exact SyntaxError message from the JavaScript regex engine — for example, an unterminated character class like [a-. Fix the highlighted part of your pattern and the results update live.

More from the codex