Faruk ToolsVisit Portfolio

Regex Tester

Test a regular expression against real JavaScript RegExp behavior: a live match table with capture groups, plus a plain-English breakdown of what the pattern actually does, piece by piece.

Nothing leaves the browser. Matching runs locally in a Web Worker (with a timeout, so a runaway pattern can’t freeze the tab) — there is no network request, no logging, and nothing is saved.

//g

Matches

Enter a pattern to get started.

This tester runs your pattern through JavaScript's actual RegExp engine — the same engine Node.js and every browser use — so what you see here is exactly how the pattern would behave in real code, including whether a non-global pattern really does stop after its first match.

Below the match table, the pattern breakdown walks through your regex piece by piece in plain English: what each group, quantifier, and character class actually means, in the order it appears. It's a from-scratch parser built for this tool, so an unusual construct it doesn't recognize falls back to a generic note rather than showing something misleading — the match table above it is unaffected either way, since that always comes straight from the real RegExp engine.

Everything runs in your browser, including matching itself — which runs in a Web Worker with a timeout, so a pattern that backtracks catastrophically gets stopped instead of freezing the tab.

How to use this regex tester

  1. 1Type a pattern (no surrounding slashes needed) and toggle flags — g for global (find every match, not just the first), i for case-insensitive, m for multiline anchors, s for dot-matches-newline, u for Unicode mode, y for sticky.
  2. 2Paste or type a test string. Matches update live as you type, with a short debounce so it doesn't re-run on every keystroke.
  3. 3Read the match table for the full match text, its position, and every capture group — numbered and named.
  4. 4Open the pattern breakdown to see the regex explained piece by piece, with nested groups indented under the group they belong to.

Regex syntax quick reference

SyntaxMeaningExample
.Any character except a line breaka.c matches abc, a c
\d \w \sDigit, word character, whitespace (capital = negated)\d+ matches 123
^ $Start / end of string (or line, with the m flag)^Hello matches at the start only
[...] [^...]A character class, or its negation[aeiou] matches any vowel
* + ? {n,m}Zero+, one+, zero-or-one, or a specific range of repeats\d{2,4} matches 2 to 4 digits
(...) (?:...)A capturing group, or a non-capturing group(\d+)-(\d+) captures two numbers
(?<name>...)A named capturing group(?<year>\d{4})
a|bAlternation — matches a or bcat|dog
(?=...) (?!...)Lookahead / negative lookahead — doesn't consume characters\d+(?= dollars)
(?<=...) (?<!...)Lookbehind / negative lookbehind(?<=\$)\d+

Frequently asked questions

Why does my pattern only find one match?+

Without the g (global) flag, JavaScript's RegExp.exec() and String.match() only ever return the first match — this is normal RegExp behavior, not a bug in the tool. Turn on the g flag to see every match in the test string.

What's the difference between greedy and lazy quantifiers?+

By default, quantifiers like * and + are greedy — they match as much as possible, then backtrack if needed. Adding a ? after them (e.g. *? or +?) makes them lazy, matching as little as possible instead. On <div>a</div><div>b</div>, <.+> greedily matches the whole string; <.+?> lazily matches just <div>.

Why did the tool say a pattern timed out?+

That's catastrophic backtracking — certain patterns (classically, nested quantifiers like (a+)+b) can take exponentially longer to fail on a non-matching string as that string grows, because the engine tries an enormous number of ways to backtrack before giving up. Real servers have been taken down by this (it's sometimes called ReDoS). This tool runs matching in a Web Worker with a timeout specifically so a pattern like that gets stopped here instead of freezing your tab — if you see a timeout, look for nested or overlapping quantifiers in your pattern.

Why doesn't a group show up in the match table?+

A capturing group only appears with a value if it actually participated in that particular match. In an alternation like (a)|(b), only one side ever matches, so the other group's value is undefined for that match — that's correct RegExp behavior, not a missing feature.

Does this support lookbehind — (?<=...) and (?<!...)?+

Yes, since this uses the real, current JavaScript RegExp engine. Lookbehind support was added to the language relatively recently (2018), so if you're targeting very old browsers or an older JS runtime in production, double-check that lookbehind is actually available there — this tester itself will always support whatever your current browser does.

What's the difference between \d, [0-9], and \p{Nd}?+

\d and [0-9] mean the same thing in JavaScript: an ASCII digit 0 through 9. \p{Nd} is a Unicode property escape (only valid with the u or v flag) matching any decimal digit in any script, not just ASCII — useful if your input might contain Arabic-Indic or Devanagari digits, for example.