Test a regular expression against sample text and see every match highlighted with its position and capture groups, updated as you type. Invalid patterns report the syntax error inline instead of failing silently.
How to use it
- Enter your pattern without the surrounding slashes.
- Set the flags you need, then paste the text you want to match against.
- Matches are highlighted in place; each is listed with its start index and any numbered capture groups.
What the flags change
The g flag finds every match rather than stopping at the first. i makes matching case-insensitive. m changes the meaning of the anchors so ^ and $ match at each line break rather than only at the boundaries of the whole string. s, sometimes called dotall, lets . match a newline, which it otherwise refuses to do. u enables full Unicode handling so astral characters such as emoji count as a single unit, and y anchors each attempt at the current position.
Groups deserve attention because they drive most real work. Plain parentheses capture and are numbered from one in the order their opening bracket appears. Prefixing with ?: creates a non-capturing group, which is what you want when you only need to apply a quantifier and do not care about the contents. Named groups written as (?<name>...) are far easier to maintain than counting brackets.
Greedy quantifiers and catastrophic backtracking
By default *, + and ? are greedy: they consume as much as possible and then give characters back until the rest of the pattern fits. Appending ? makes them lazy, matching as little as possible. The classic bug is using <.*> to match a single HTML tag and finding it swallows the entire line, where <.*?> behaves as intended.
More dangerous is catastrophic backtracking. Nested quantifiers over overlapping alternatives, the pattern (a+)+$ being the textbook example, can make the engine explore exponentially many paths on a non-matching input, freezing the page or hanging a server. That failure mode is a real denial-of-service class known as ReDoS. If a pattern is slow on a modest string, restructure it with anchors, atomic alternatives or a stricter character class rather than hoping the input stays small. Everything here executes in your own browser using the native JavaScript engine, so the text you test is never uploaded.
Frequently asked questions
Why does my pattern behave differently in Python or PCRE?
This tool uses the JavaScript engine, and dialects genuinely differ. JavaScript has no lookbehind in very old environments, spells word boundaries and Unicode property escapes differently, and does not support atomic groups or possessive quantifiers at all. Test against the engine you will actually deploy on.
How do I match a literal dot or slash?
Escape it with a backslash: \. matches a full stop rather than any character. Inside a character class most metacharacters lose their special meaning, so [.] works too. Since you enter the pattern without delimiters here, forward slashes need no escaping.
Is my test data sent anywhere?
No. Both the pattern and the sample text stay in your browser, which means you can safely test against log excerpts or other sensitive strings.
Related tools: JSON Formatter, Cron Explainer, Hex / ASCII Converter.