Test a regular expression
Test a JavaScript regular expression against text with highlighted matches, capture groups and a timeout guard.
0 / 100,000 characters · Updates as you type.
Type a pattern and a test string and see every match highlighted in place, with a table of match positions, numbered capture groups and named groups. The engine is your browser's own JavaScript RegExp, so the behaviour is exactly what you will get in Node.js or a web app, including flags g, i, m, s and u.
Some patterns, typically nested quantifiers such as (a+)+ against a long non-matching string, backtrack exponentially and can freeze a page. Here the match runs in a Web Worker and is killed after 2 seconds, so a bad pattern costs you a message, not a browser tab. Pattern length is capped at 1,000 characters and the test string at 100,000.
Matches are rendered as text nodes, never as HTML, so a test string containing markup is displayed literally and cannot inject anything into the page.
How to use it
- Enter the pattern without slashes, for example \d{4}-\d{2}-\d{2}.
- Tick the flags you need. g is on by default so every match is shown; turn it off to see only the first.
- Paste the text to test. Matches highlight as you type.
- Read the table for each match's index and its groups. Copy or download the list of matched strings.
Frequently asked questions
Which regex flavour is this?
ECMAScript (JavaScript). Lookbehind, named groups and Unicode property escapes (\p{...} with the u flag) work in current browsers. PCRE-only features such as possessive quantifiers, atomic groups and \A are not supported.
Why did my pattern time out?
It probably contains a quantified group inside another quantifier, such as (\w+\s?)+, which makes the engine try an exponential number of splits when the match fails near the end. Make the inner parts mutually exclusive or anchor the pattern.
How do I match across lines?
Use the s flag so the dot matches newline characters, and the m flag if ^ and $ should match at each line rather than only at the ends of the whole string.
Does the tool support replace?
Not yet. It shows matches and groups, which is usually enough to write the replacement in your code with String.prototype.replace.
Is my text uploaded?
No. Matching runs in a Web Worker in your browser and nothing is transmitted.
Related tools
- Validate JSON and locate the errorCheck whether text is valid JSON and see exactly where it breaks, with line, column and a caret.
- Format, beautify or minify JSONPretty-print or minify JSON with 2-space, 4-space or tab indentation and optional key sorting.
- URL-encode or decode textPercent-encode text for URLs (encodeURIComponent or encodeURI) or decode an encoded string.
- Encode or decode Base64Encode text to Base64 or decode Base64 back to text, UTF-8 safe, with a URL-safe option.