Regex Tester

Live Matches & Capture Groups

Test JavaScript regular expressions with live match highlighting, capture groups, and g, i, m flag controls. Browser-only JS engine—not PCRE or Python.

This conversion runs only in your browser — nothing is uploaded.

Flags
  • Matches
  • Flagsg
  • Test string0

Test string

Output

Output...

What is this tool?

This regex tester compiles a JavaScript pattern in your browser, runs it against a test string, and shows live match highlighting, match count, and capture groups. Toggle the familiar g, i, and m flags without slash delimiters around the pattern.

Behavior matches the browser’s ECMAScript RegExp engine—not PCRE, Python, Java, .NET, or RE2. Use it to prototype validators, log extractors, and filename rules before you paste the pattern into application code.

Common use cases

  • Debug why a form validator accepts or rejects a sample string
  • Extract IDs or key=value pairs from a short log snippet with capture groups
  • Compare greedy .* vs lazy .*? (and multiline ^/$) on the same text

How to use

  1. Enter a pattern without /…/ delimiters (e.g. \d+ or (\w+)=(\S+)).
  2. Toggle g (all matches), i (ignore case), and m (^/$ per line).
  3. Paste a test string. Matches highlight live; capture groups list below when present.
  4. Use Sample for a multiline key=value example, Copy for the match/capture summary, Clear to reset.

Examples

Pattern / flagsTest stringResult
\d+ · gOrder 123 and 456Two matches: 123, 456.
user-(\d+)user-42Match user-42; capture 42.
^id=.*$ · muser=a / id=42 (two lines)Matches the id=42 line only (m enables line ^/$).
<(.+)> vs <(.+?)> · g<a>x</a><b>y</b>Greedy takes one wide match; lazy takes shorter tag spans (edge vs greedy).
[ (broken)anyInvalid regex error.

Practical pitfalls

  • Engine mismatch: a pattern tuned in Python/re or PCRE may fail or differ under JavaScript (lookbehind, possessive quantifiers, Unicode classes).
  • Greedy by default: .* crosses delimiters you did not intend—prefer lazy quantifiers or tighter classes.
  • ReDoS / long input: nested quantifiers on large pastes can stall the tab. Keep the test string short while iterating; this page does not sandbox or time-limit the engine.

References

Last reviewed: 2026-07-27

Frequently asked questions

Which regex engine is used?
The browser’s JavaScript RegExp engine. Lookbehind, Unicode property escapes, and backtracking follow ECMAScript—not PCRE, Python, Java, .NET, or RE2. Patterns that work in those engines may fail or behave differently here.
What do the g, i, and m flags do?
g (global) finds every match; without it only the first match is shown. i ignores case. m makes ^ and $ match line starts/ends, not only the whole string.
Why does my “greedy” pattern swallow too much?
Quantifiers like .* and .+ are greedy by default and take the longest match. Use .*? or .+? for a lazy (shortest) match, or tighten the character class so it cannot cross the boundary you care about.
Can a pathological pattern freeze the tab?
Yes. Nested quantifiers on long input (classic ReDoS shapes) can make the JS engine backtrack heavily. Keep samples short while debugging; do not paste huge logs into catastrophic patterns.