See What Your Regular Expression Actually Matches
Regular expressions are the most powerful text-processing notation ever crammed into one line — and the easiest to get subtly wrong. The difference between .* and .*?, a forgotten anchor, an unescaped dot: each produces a pattern that almost works, which is worse than one that fails loudly. The cure is seeing matches as you type, and that is exactly what this tester does: enter a pattern and a sample text, and every match lights up instantly, with capture groups listed below. The engine is your browser's own JavaScript regex implementation, so what matches here is precisely what will match in your JavaScript code.
How to Use It
- Type your pattern in the regex field — without surrounding slashes.
- Toggle flags: g (find all matches, not just the first), i (ignore case), m (anchors match per line), s (dot matches newlines).
- Paste sample text. Matches highlight live; a counter reports how many.
- Inspect the match list: each entry shows the full match, its position, and every numbered and named capture group.
- Syntax errors in the pattern appear immediately with the engine's message — no silent failure.
A Ten-Line Refresher on the Notation
.any character —\ddigit —\wword character —\swhitespace (capitals negate:\Dnon-digit).*zero or more —+one or more —?optional —{2,5}between two and five.^start,$end —[abc]any of these —[^abc]none of these —a|beither.(…)capture group —(?:…)group without capturing —(?<name>…)named group.- To match a literal dot, plus or parenthesis, escape it:
\.\+\(.
The Mistakes the Highlighter Catches Fastest
Greedy quantifiers: ".*" against text with two quoted strings matches from the first quote to the last — the highlight makes the overreach obvious, and switching to ".*?" (lazy) fixes it visibly. Missing the g flag: only the first match lights up, a one-toggle diagnosis. Unescaped metacharacters: a dot intended literally happily matches everything, which the highlight betrays at a glance. Anchor confusion: with multi-line samples, watching ^ behave differently as you toggle the m flag teaches the concept faster than any documentation.
Practical Notes
This tester speaks the JavaScript regex dialect. The core notation is portable everywhere, but a few advanced features differ between languages — lookbehind support, possessive quantifiers and some character-class shorthand vary in Python, PCRE and Java — so for non-JavaScript targets, treat a passing test here as strong but not absolute evidence. Build complex patterns incrementally: get the literal core matching first, add quantifiers, then anchors, then groups, watching the highlights at each step; five small verified steps beat one heroic untested expression. Your patterns and sample text stay in the page — paste production log excerpts freely, because nothing you test here is transmitted anywhere.
Patterns Worth Stealing
A few battle-tested starting points for common jobs, each ready to paste and adapt: emails match well with [\w.+-]+@[\w-]+\.[\w.]+; a number with optional decimals is -?\d+(\.\d+)?; text between double quotes is "([^"]*)" with the content captured in group one; trailing whitespace per line is \s+$ with the m flag; and a date like 2026-06-11 is \d{4}-\d{2}-\d{2}. None of these is perfect for every edge case — no short regex is — but each is the right 90-percent solution to start refining against your own sample text.
Frequently Asked Questions
Why does my pattern only highlight the first match?
The g (global) flag is off. Without it, a regex stops at the first match — toggle g on and every occurrence in the sample lights up.
Why does ".*" match more than I expected?
Quantifiers are greedy by default: .* grabs the longest possible stretch. Add ? for the lazy version (.*?), which stops at the earliest valid endpoint — the highlight shows the difference instantly.
Will my pattern work the same in Python or PHP?
The core syntax is portable, but dialects differ in advanced features (lookbehind, possessive quantifiers). This tester uses JavaScript’s engine, so verify exotic constructs in the target language too.
How do I see what my capture groups extracted?
The match list below the text shows every match with its numbered and named groups expanded — exactly the values your code would receive from each match.