πŸ§ͺ Regex Tester

Test JavaScript regular expressions with live match highlighting, capture groups, and substitution preview. Includes 12+ common preset patterns.

/
/
Test string β€”
Matches 0 matches
Substitution
β€”
Preset patterns
Regex cheat sheet
SyntaxMeaningExample
.Any character except newlinea.c matches "abc", "a1c"
\d \w \sDigit / word / whitespace\d+ = one or more digits
\D \W \SNon-digit / word / whitespace
[abc]Character class[aeiou] = any vowel
[^abc]Negated class[^0-9] = anything but digits
^ $Start / end of string (or line with m flag)^hello = starts with "hello"
\bWord boundary\bcat\b matches "cat" not "cats"
* + ?0+ / 1+ / 0-or-1 (greedy)a+ = one or more a's
{n,m}Between n and m repetitions\d{4} = 4 digits
*? +? ??Lazy versions<.+?> = shortest tag
(abc)Capture group(\w+)@(\w+)
(?<name>abc)Named capture(?<year>\d{4})
(?:abc)Non-capturing group
a|bAlternationcat|dog
(?=abc) (?!abc)Lookahead pos/neg\d+(?=px) = digits before "px"
(?<=abc) (?<!abc)Lookbehind pos/neg(?<=\$)\d+ = digits after "$"
Copied

About Regex Tester

Regex Tester is a browser-based tool for writing, debugging, and validating JavaScript regular expressions. Type a pattern and a test string β€” matches are highlighted live, capture groups are broken out per match, and a substitution box lets you preview what a .replace() call would produce. Twelve+ preset patterns cover the most common needs (email, URL, IPv4/IPv6, hex color, ISO date, phone, UUID, semver, credit card, and more).

The engine is your browser's native JavaScript regex β€” the exact same engine that runs your app. No dialect surprises, no server round-trip, no signup. Everything happens client-side.

Uses JavaScript's regex flavor. Most patterns work across languages, but details differ β€” PCRE (PHP), Python re, Java, and .NET have small variations in named groups, lookbehind support, and escape semantics. Test in your target language before deploying.

How to use

1

Type your pattern

Enter the regex in the top box. Toggle flags with the letter buttons (g, i, m, s, u, y).

2

Paste your test string

The text panel is your test corpus. Matches highlight in real time with a subtle purple background.

3

Inspect groups

The right panel shows every match with its position and any capture groups (named or numbered).

4

Test substitution

Type a replacement pattern β€” $1, $<name>, $& work β€” and see the output.

Key Features

Live highlighting

Match highlights update every keystroke via an overlaid DOM. No "Run" button, no lag β€” just type.

Flag toggle buttons

Click g i m s u y to enable each. Tooltips explain what each flag does. Sticky y is included for anchored parsing.

Match list with groups

Each match shows index, character position, and every capture group β€” named groups keyed by name, positional groups by $1, $2, etc.

Substitution preview

Type a replacement string. Standard back-references work: $1-$99, $<name>, $& (whole match), $` (before), $' (after), $$ (literal $).

12+ preset patterns

Email, URL, IPv4, IPv6, hex color, phone (E.164), ISO 8601 date, credit card (basic), UUID, semver, US postal code, HTML tag, JSON string. One-click to load pattern + suitable test string.

Escape input helper

Click "Escape input" to turn the current pattern box into a literal string β€” useful when you want to match text that contains ., *, +, or other special chars.

Copy β€” pattern, JS literal, matches, replaced output

Grab the raw /pattern/flags, a JS-literal (new RegExp("...", "gi") equivalent), the list of match strings, or the substituted output.

Regex cheat sheet

Compact reference of quantifiers, character classes, anchors, groups, and lookarounds right on the page.

Common Use Cases

  • Writing a validator for email / URL / phone input
  • Extracting all links from a chunk of HTML
  • Building a log-line parser for CI or observability
  • Cleaning up user data β€” remove ANSI codes, control chars, extra whitespace
  • Grepping through a large text sample before writing the real script
  • Testing capture groups before dropping them into .match() or .matchAll()
  • Debugging why your regex isn't matching what you expected
  • Learning regex through preset patterns
  • Prototyping a find-and-replace transformation
  • Verifying complex patterns from Stack Overflow before pasting into production

Security & Privacy

  • 100% client-side: pattern + test string never leave your device.
  • Works offline: disconnect after page load and it still works.
  • Catastrophic backtracking safeguard: patterns run in your browser's regex engine which may hang on pathological inputs. If you paste a suspicious pattern from the internet, use short test strings first.
  • No account, no logging.

Frequently Asked Questions

JavaScript ECMAScript regex β€” the engine built into your browser. It supports named groups ((?<name>...)) and full lookbehind since ES2018. Most patterns are portable, but PCRE (PHP), Python re, Java, and .NET have small differences. When in doubt, test in the target language.
g tells the regex to find all matches instead of just the first. Without it, String.prototype.matchAll() throws and .replace() only replaces the first occurrence. This tester enables g by default so you see every match at once.
Almost always catastrophic backtracking β€” nested quantifiers like (a+)+ or overlapping alternations. The engine tries exponentially many combinations. Fix: rewrite without nested quantifiers, use possessive/atomic groups (not supported in JS β€” use lookaheads as workaround), or add anchors.
.* is greedy β€” matches as much as possible then backtracks. .*? is lazy β€” matches as little as possible. For extracting HTML tags, <.*?> gives you just <p> while <.*> gives you <p>text</p>.
Backslash-escape it: \., \*, \+, \(, etc. The "Escape input" button does this to your entire current pattern for you.
No. Everything is in-browser. Verify with DevTools β†’ Network. You can disconnect from the internet after page load and the tester still works.
Yes β€” no signup, no ads, no limits.