Matches highlight देखने के लिए एक test string दर्ज करें।
कोई match नहीं।
Critique this regex for catastrophic backtracking and RE2 compatibility, then propose a stricter version with tradeoffs: `//gi` Matches found: (none)
(Documentation in English)
What it does
Tests a JavaScript regular expression against any text, live as you type. Type a pattern, toggle any of the six flags (g global, i ignore case, m multiline, s dotAll, u unicode, y sticky), and the tool lists every match with its index and capture groups, highlights all hits in the test string, and shows the constructed /pattern/flags literal ready to copy.
It uses your engine’s native RegExp - the same semantics your code will get - and reports invalid patterns with the engine’s own error message (e.g. missing terminating ] for character class) instead of a generic failure. Matching is capped at 2000 matches, and zero-width matches are detected and displayed as thin markers rather than hanging the loop. 100% in-browser.
How to use it
- Click a preset in the toolbar - Email, URL, Date, Hex color, or Capture - to load a ready-made pattern, flag set, and sample text. Each preset sets all six flags explicitly, so switching presets never leaves a stale flag on.
- Type your pattern in the Pattern field (shown between
/delimiters, with the active flags appended live). Click Copy in the section header to copy the full/pattern/flagsliteral. - Toggle any of the six Flags; each toggle shows its name and a one-line hint (e.g.
sdotAll - “. also matches newlines”). Defaults areg+i. - Type or paste text into Test string - the row label shows the live match count.
- Watch the Match preview: every hit is outlined; zero-length matches appear as a thin bar so you can see where they land.
- Read Matches: one card per match with
#n @ index, the matched text, and each capture group ([1],[2], …) with(undefined)for groups that did not participate. - Click Clear (toolbar) to reset pattern, flags, and test string in one tap.
- Below the output, the prompt bar copies a pre-filled AI prompt built from your live values - Critique & improve (checks the pattern for catastrophic backtracking) or Generate Python tests (writes
reunit tests from the current matches).
Examples
Verified by running the tool’s exact matching loop (same RegExp construction and exec walk as the island) on the built-in presets:
Email preset /[\w.+-]+@[\w-]+\.[\w.]+/gi on Contact ada@example.com or bob@test.co.uk today.
1. "ada@example.com" @ 8
2. "bob@test.co.uk" @ 27
Capture preset /(\w+)@(\w+)/g on ada@example bob@test - groups listed per match:
1. "ada@example" @ 0 → [ada, example]
2. "bob@test" @ 12 → [bob, test]
Hex color preset /#(?:[0-9a-f]{3}|[0-9a-f]{6})\b/gi on Brand #3b82f6, accent #38BDF8, short #fff.
1. "#3b82f6" @ 6
2. "#38BDF8" @ 22
3. "#fff" @ 37
No g flag - only the first match is reported. Pattern /\d{4}-\d{2}-\d{2}/ on Shipped 2026-08-15, due 2026-09-01. → 1. "2026-08-15" @ 8 (with g, both dates match: @ 8 and @ 24).
Zero-width pattern /\b/g on ab → two empty matches at @ 0 and @ 2, rendered as thin markers in the preview.
Good to know
- Private: matching runs entirely in your browser; nothing you paste is uploaded.
- The dialect is ECMAScript (
RegExp). Lookbehind, named groups, andu-mode properties work if your browser supports them - the tool imposes nothing on top. - The
y(sticky) flag makes matches start atlastIndex, so a sticky pattern often yields zero matches until the text aligns - that is the flag working, not a bug. - Empty test string shows a hint instead of a preview; an invalid pattern keeps the text visible with the engine’s error below it.
- Related tools: Regex Explainer, Find & Replace, Text Diff Viewer