Extracting a repeated token
Use the global flag to locate every non-overlapping occurrence in a representative sample.
Include strings that should not match; positive examples alone encourage patterns that are too broad.
Test JavaScript regular expressions against sample text with live match highlighting, capture groups, match counts, and flag controls.
Content last reviewed
60 characters · 1 lines
2 matches
Overview
Enter a RegExp pattern, select flags, and inspect non-overlapping matches with numbered capture groups. The loop guards against zero-length global matches, but evaluation is synchronous and a pathological backtracking pattern can still make the tab unresponsive.
Patterns are compiled with new RegExp, so support follows this browser rather than PCRE, Python, Java, or .NET.
The flag field accepts g, i, m, s, u, and y; quick toggles cover g, i, m, and s.
Every global result—or the first result without g—is marked in the original test string.
Captured values from each match are listed as $1, $2, and so on.
How it works
Three steps, in the order the tool above actually takes them.
Use JavaScript RegExp source without surrounding slash delimiters.
Choose global, case, multiline, dotall, Unicode, or sticky behavior as the target runtime requires.
Check boundaries and negative examples, then retest the final pattern in the application runtime.
Use cases
The jobs this page is usually opened for, and the setting that makes each one quick.
Use the global flag to locate every non-overlapping occurrence in a representative sample.
Include strings that should not match; positive examples alone encourage patterns that are too broad.
Compare ^ and $ with and without the multiline flag over actual multi-line input.
Dotall changes dot behavior; multiline changes anchors. They solve different problems.
Confirm which subexpressions populate numbered groups for each match.
This interface lists numbered captures; test replacement syntax and named groups in the destination code separately.
A pattern belongs to a runtime
Similar-looking regex flavors diverge at advanced features, and some nested alternatives grow dramatically on near-matching input. A browser success is evidence for this JavaScript engine only.
| Concern | Unsafe conclusion | Useful test |
|---|---|---|
| Flavor | A JavaScript match guarantees Python, PHP, or .NET behavior. | Compile and test the pattern with the target engine and version. |
| Global flag | g changes what one match means. | It continues the scan for non-overlapping matches and makes RegExp stateful in application code. |
| Greediness | .* always stops at the nearest delimiter. | It is greedy; use a lazy quantifier or a delimiter-excluding class when that reflects the grammar. |
| Backtracking | A quick short sample proves the pattern is safe on long hostile input. | Test size and near-miss cases, bound input, and avoid ambiguous nested repetition. |
A JavaScript match guarantees Python, PHP, or .NET behavior.
Compile and test the pattern with the target engine and version.
g changes what one match means.
It continues the scan for non-overlapping matches and makes RegExp stateful in application code.
.* always stops at the nearest delimiter.
It is greedy; use a lazy quantifier or a delimiter-excluding class when that reflects the grammar.
A quick short sample proves the pattern is safe on long hostile input.
Test size and near-miss cases, bound input, and avoid ambiguous nested repetition.
Privacy
The pattern and test text are compiled and matched in this tab. Neither is uploaded or autosaved.
Encoding, parsing, formatting, generation, comparison, and cryptographic operations run in browser code. Form values and uploaded text files are not sent to a processing API.
Code, tokens, secrets, URLs, and generated outputs stay in component memory until the page reloads or closes. Split-pane tools remember only the divider percentage for the current tab session.
The page reads the clipboard only after a Paste action and writes it only after Copy. A local download is created only when you choose the tool's download control.
The page shell can send the tool slug, never the editor contents or filename. The endpoint is rate-limited using a transient requesting address and is skipped for Do Not Track or Global Privacy Control.
More detail in how processing works and our privacy policy.
Limits
The values this tool actually enforces, not a rounded-up version.
JavaScript regular expressions only, as implemented by your browser. There is no PCRE, Python or .NET mode, no replacement preview, and no explanation of what a pattern means — it shows what a pattern does against the input you supply. Very large inputs combined with a catastrophically backtracking pattern can block the tab, because matching is synchronous.
FAQ
The ones that actually come up.
Guides