Regex explainer
What does this regex do?
Every group, quantifier, class and assertion, glossed in plain English. Hover a line to see which part of the pattern it describes.
Valid pattern · 2 capture groups (2 named) · 5 quantifiers · 1 lookaround · flags g
gglobal: Find every match instead of stopping after the first one.
(?<=\$)Positive lookbehind. Checks, without consuming any characters, that the text right before this position matches the items below.JavaScript allows any pattern inside a lookbehind, including variable-length ones like a+. Python, PCRE, Java and Go are stricter.\$Escaped character. Matches “$”, escaped so that it is not read as regex syntax.
(?<dollars>\d{1,3}(?:,\d{3})*)Named group “dollars” (#1). Matches the items below and saves the text as group “dollars” (match.groups.dollars, also match[1]).\d{1,3}Quantifier {1,3}. Repeats the item below between 1 and 3 times, as many times as possible (greedy), giving some back if the rest of the pattern needs it.\dDigit. Matches one ASCII digit, 0–9. Other scripts’ digits (such as ٣) are not included; use \p{Nd} with the u flag for those.
(?:,\d{3})*Quantifier *. Repeats the item below zero or more times, as many times as possible (greedy), giving some back if the rest of the pattern needs it.(?:,\d{3})Non-capturing group. Groups the items below without saving what they match, usually to apply a quantifier or to limit an alternation.,Character. Matches “,”.\d{3}Quantifier {3}. Repeats the item below exactly 3 times.\dDigit. Matches one ASCII digit, 0–9. Other scripts’ digits (such as ٣) are not included; use \p{Nd} with the u flag for those.
(?:\.(?<cents>\d{2}))?Quantifier ?. Makes the item below optional: it matches once or not at all, preferring to match it (greedy).(?:\.(?<cents>\d{2}))Non-capturing group. Groups the items below without saving what they match, usually to apply a quantifier or to limit an alternation.\.Escaped character. Matches “.”, escaped so that it is not read as regex syntax.(?<cents>\d{2})Named group “cents” (#2). Matches the items below and saves the text as group “cents” (match.groups.cents, also match[2]).\d{2}Quantifier {2}. Repeats the item below exactly 2 times.\dDigit. Matches one ASCII digit, 0–9. Other scripts’ digits (such as ٣) are not included; use \p{Nd} with the u flag for those.
\bWord boundary. Matches at a position between a word character (A–Z, a–z, 0–9, _) and a non-word character or the edge of the text.Letters such as é or ж are not word characters for \b, even with the u flag.
How to read the breakdown
Paste or type a JavaScript regular expression between the slashes and switch on the flags it uses. The explanation is a tree that follows the structure of the pattern: a quantifier sits above the item it repeats, a group above its contents, and an alternation lists each option on its own branch. Hover any line and the part of the pattern it explains is highlighted above.
Capture groups keep the same colour everywhere on RegexQuill, so group 2 in this tree is the same colour as group 2 in the tester’s match table. Lines marked N.B. point out legacy syntax that only works without the u or v flag, constructs other regex flavours handle differently, and common traps such as [A-z], which also matches [, \, ], ^, _ and a backtick.
The parser follows the ECMAScript 2025 grammar, including lookbehind, named and duplicate named groups, Unicode property escapes, v-flag set operations and pattern modifiers. Your browser’s own RegExp engine double-checks every pattern, so an error shown here is exactly what your code would throw.
Questions
Can it explain regexes from Python, PHP or Java?
Mostly. Common syntax is shared, but flavour-specific constructs such as possessive quantifiers, atomic groups or Python’s (?P<name>…) are not JavaScript and are reported as syntax errors.
Why is my pattern valid without u but an error with it?
Without u or v, browsers accept legacy syntax such as a lone ] or { and unnecessary escapes like \k. Unicode mode turns those into errors so that typos are caught.
Is the pattern sent anywhere?
No. The explanation is generated in your browser.