Regex Tester & Match Extractor
Test regular expressions against real text. Highlight matches, inspect numbered and named capture groups, preview find-and-replace operations, and export the results. Matching runs locally in your browser.
Build your expression
Enter a JavaScript regex pattern without the surrounding slash delimiters, then select the flags to use.
Quick examples
Load a working example to test common extraction and replacement tasks.
$& for the entire match,
$1 for capture group 1, $<name>
for a named group and $$ for a literal dollar sign.
Ready to test.
Test result
The match list is capped at 300 entries to keep the interface responsive.
Highlighted matches
Highlighting shows the matched ranges for the displayed matches.
Match details & capture groups
Match positions are zero-based JavaScript string indexes. Numbered and named capture groups are listed when present.
Replacement preview
This is the result from the native JavaScript String.replace()
operation using the current pattern, flags and replacement string.
Regular expression cheat sheet
These examples use JavaScript syntax. Exact behavior can differ between regex engines.
| Pattern | Meaning | Example |
|---|---|---|
. | Any character, except line terminators unless dot-all is enabled | a.c |
\d | ASCII digit | \d{4} |
\w | ASCII word character in common usage | \w+ |
\s | Whitespace character | \s+ |
[abc] | One character from the set | [aeiou] |
[^abc] | One character not in the set | [^0-9] |
{2,4} | Repeat the previous item 2–4 times | \d{2,4} |
(...) | Capturing group | (\d{4}) |
(?:...) | Non-capturing group | (?:https?|ftp) |
(?<year>...) | Named capturing group | (?<year>\d{4}) |
^ and $ | String boundaries, or line boundaries with multiline flag | ^Hello$ |
\b | Word boundary | \bcat\b |
(?=...) | Positive lookahead | \d(?=px) |
(?!...) | Negative lookahead | foo(?!bar) |
How to use this regex tester
- Enter the expression without surrounding slash delimiters.
- Choose the flags, such as global matching and case-insensitive matching.
- Paste the text you want to inspect and run the test.
- Review the highlighted matches, indexes and capture groups.
- Optionally enable replacement preview, then copy or export results.
Understanding regex flags
- g — Global: find multiple non-overlapping matches rather than only the first.
- i — Ignore case: ignore case differences where the JavaScript engine allows.
- m — Multiline: make
^and$recognize line boundaries. - s — Dot-all: allow
.to match line terminators. - u — Unicode: enable Unicode-aware regex processing.
- y — Sticky: match at the current
lastIndexposition rather than searching forward.
What are capture groups?
Parentheses can capture part of a match. Numbered capture groups are
assigned from left to right, while named groups label the captured
values. For example,
(?<year>\d{4})-(?<month>\d{2})
creates named captures for a four-digit year and a two-digit month.
Testing a pattern is not the same as validating the data
A regex can check whether a date string resembles 2026-10-17
without confirming that every matched date is a real calendar date.
Similar limits apply to email addresses, URLs and phone numbers. Use a
domain-specific validator when the actual value must be correct.
Why the tool has a timeout
Some regex patterns can take a long time on certain input strings. This tool runs matching in a separate temporary Web Worker and stops it after a time limit. That reduces the risk of a slow pattern freezing the page, but it does not guarantee that every expression is safe or fast.
JavaScript syntax versus other regex engines
This tester uses your browser's JavaScript RegExp engine.
Patterns written for Python, PCRE, Java, .NET, Ruby or other engines
may behave differently. If your production code uses another engine,
test the expression in a tool that supports that particular flavor.
Frequently asked questions
Why is only one match shown?
Without the global flag g, JavaScript matching typically
stops after the first result. Enable the flag when you want all
non-overlapping matches.
Does this tool upload my pattern or sample text?
The matching is performed in a browser Web Worker. No server-based regex service is required. Avoid entering sensitive production data on websites unless you understand the entire site's data handling.
Does this regex tester guarantee that my pattern is secure?
No. A successful test only shows how the chosen pattern behaves on the supplied sample. It is not a formal ReDoS security audit or proof that a pattern will be efficient for every input.
Can I export the matches?
Yes. You can copy the match list or download a CSV containing match indexes, matched text, and capture-group details for the entries shown by the tool.
Learn more
Consult the MDN JavaScript regular expression guide for syntax and examples, and the MDN Worker termination reference for how a Web Worker can be stopped.