Free Online Regex Tester, Debugger & Builder
Test, explain, and debug regex in real-time. Verify edges cases with unit-test assertions and instantly generate code snippets to export your logic.
Unit Testing Assertions
Mastering Regular Expressions
Greedy vs. Lazy Matching
By default, regex quantifiers like * (zero or more) and + (one or more) are greedy. They consume as many characters as mathematically possible before satisfying the rest of the pattern.
For example, running <.*> against <div>Hello</div> will match the entire string, instead of just the first <div> tag. To fix this, append a ? to the quantifier (e.g., <.*?>). This makes the match lazy (or ungreedy), forcing the engine to evaluate the shortest possible match instead, returning exactly <div>.
Understanding Capture Groups
Parentheses (...) serve two purposes in regex: grouping logic together, and extracting out exact substrings. When you write (\d4)-(\d2)-(\d2) to match a date, the engine will extract three numbered arrays representing the year, month, and day.
Pro-tip: Named Capture GroupsInstead of relying on index numbers (`$1`, `$2`), you can assign strict variable names to your groupings using the syntax (?<name>...). For example: (?<year>\d4). Now, in code languages like Python or JavaScript, your match object will securely map the matched digits to a groups.year property, immune to indices changing.
Common Questions
What does cross-dialect compatibility mean?
Languages use subtly different regex "engines". JavaScript runs under V8, which recently adopted negative lookbehinds but historically didn't support them. PHP uses PCRE, which is hyper-fast and features advanced recursion. Python strictly requires re.DOTALL instead of parsing inline /s flags. Use our "Dialect Reference" toggle to see the gotchas.
Does your tool evaluate code locally?
Yes. We never send your strings or regex logic over network. The tool evaluates 100% locally within your browser tab, ensuring maximum privacy for production keys and sensitive parsing data.
About Regex Tester
A regex is a tiny language for describing string patterns — useful for validation, extraction, search-and-replace, and parsing. Writing one correctly the first time is rare; you iterate. A tester gives you immediate feedback: which characters matched, which groups captured what, and which flags changed the behavior. This tool runs your pattern against your sample text on every keystroke, with full ECMAScript semantics.
What this tool does
- Live highlighting — every match in your sample is colored as you type.
- Group breakdown — numbered and named captures shown per match.
- Flag toggles —
g,i,m,s,u,ywith hover descriptions. - Replace mode — preview substitutions with
$1,lt;name>, and backrefs. - Cheatsheet — common tokens, anchors, and Unicode property escapes.
Common pitfalls
Greedy quantifiers (.*) match as much as possible — use the lazy form (.*?) when you want the shortest match. The dot does not match newlines unless you set the s flag. Anchors ^ and $ change meaning under the multiline flag m. Word boundaries (\b) are ASCII-only by default; for Unicode-aware boundaries, set u and use property escapes like \p{L}. When testing email or URL patterns, prefer the URL constructor over a hand-rolled regex — RFC-compliant matching is harder than it looks.
Pipeline
A working pattern can be sent to:
- Regex Visualizer — render your pattern as a railroad diagram.
- Data Masker — apply your regex as a custom redaction rule across PII profiles.
- Line Tools — filter lines that match (or do not match) the pattern.
Privacy
Patterns and sample text never leave your browser. The matcher runs locally on every keystroke. Read our privacy policy.
Frequently asked
- Which regex flavor does it use?
- JavaScript / ECMAScript regex, the same engine your browser ships with. That is close to but not identical to PCRE, .NET, or Python re. Lookbehinds, named groups, and Unicode property escapes are supported in modern browsers.
- Does it support lookbehinds?
- Yes — both fixed-width and variable-width lookbehinds work in any browser based on V8, JavaScriptCore, or modern Gecko. Patterns like (?<=foo)bar match correctly.
- How do named capture groups work?
- Use (?<name>pattern) to name a group, then reference it as match.groups.name in the result panel. Named groups also work with backreferences as \k<name> inside the pattern.
- Can I save patterns?
- Recent patterns are stored in your browser via IndexedDB and shown in the History page. Nothing is synced across devices. Clear browser data to delete them.