Regex Tester
Test regular expressions against text with live matching, capture groups, and replace mode
Regex Quick Reference
Character Classes
.Any character (except newline)\dDigit [0-9]\DNon-digit\wWord char [a-zA-Z0-9_]\WNon-word character\sWhitespace\SNon-whitespace[abc]Character set (a, b, or c)[^abc]Negated set[a-z]RangeQuantifiers
*0 or more+1 or more?0 or 1 (optional){n}Exactly n times{n,}n or more times{n,m}Between n and m times*?Lazy (non-greedy) *+?Lazy (non-greedy) +Anchors & Groups
^Start of string/line$End of string/line\bWord boundary(abc)Capturing group(?:abc)Non-capturing group(?<name>abc)Named groupa|bAlternation (a or b)\1Backreference to group 1Lookahead & Lookbehind
(?=abc)Positive lookahead(?!abc)Negative lookahead(?<=abc)Positive lookbehind(?<!abc)Negative lookbehindFlags
gGlobal: find all matchesiCase insensitivemMultiline: ^ $ match linessDotall: . matches newlinesuUnicode supportReplacement Tokens
$1First capture group$2Second capture group$&Entire match$`Before the match$'After the match$$Literal $Type a regex pattern, paste your test string, and see every match highlighted as you go — no need to keep rerunning scripts after each tiny edit. Capture groups, indexes, and a built-in replace mode are all visible at once. And everything runs in your browser. Nothing gets uploaded.
How It Works
The tool compiles your regex using JavaScript's native RegExp engine on every keystroke. It runs the pattern against your test string and highlights every match in real time. Capture groups, indexes, and match lengths are pulled from the result object and displayed below the panes. Turn on Replace mode and it calls String.replace() with your substitution string — including group backreferences like $1.
Examples
Extracting email addresses from a paragraph
You have a block of text and need to pull out every email. One pattern, global flag on.
Pattern: [\w.+-]+@[\w-]+\.[\w.]+
Text: Contact [email protected] or [email protected] for info.
Match 1: [email protected]
Match 2: [email protected]
Validating a date format (MM/DD/YYYY)
Quick check to see if user input matches the expected date shape. Not perfect validation, but catches obvious typos fast.
Pattern: ^(0[1-9]|1[0-2])/(0[1-9]|[12]\d|3[01])/\d{4}$
Text: 03/25/2026
Full match: 03/25/2026
Group 1: 03
Group 2: 25
Find-and-replace with capture groups
You need to reformat names from "Last, First" to "First Last" across a whole CSV column. Capture groups do the heavy lifting.
Pattern: (\w+),\s*(\w+)
Replace: $2 $1
Text:
Smith, John
Doe, Jane
Garcia, Maria
John Smith
Jane Doe
Maria Garcia
Who Uses This
Testing input validation patterns before dropping them into production code.
Writing extraction patterns for messy log files and CSV cleanup scripts.
Learning regex syntax with instant visual feedback instead of reading dry documentation.
Building log-parsing rules for Grafana, Datadog, or custom monitoring pipelines.
Common Mistakes
A dot . matches any character, not just a literal period. If you want an actual dot (like in an IP address or filename), write \. instead. Same goes for (, +, *, and other metacharacters.
Your pattern matches the first occurrence and then stops. You expected it to find all 15 matches in your text. Turn on the g flag — without it, the engine quits after the first hit.
The pattern <.+> on <b>bold</b> matches the whole thing — from the first < to the last >. Add a ? after the quantifier (<.+?>) to make it lazy. It will stop at the nearest closing bracket.
^ and $ match start/end of the entire string by default. If your test string has multiple lines and you want per-line matching, turn on the m (multiline) flag. Without it, only the very first and very last positions count.
Technical Details
- Processing: 100% client-side — uses JavaScript's native RegExp engine
- Browser Support: Chrome, Firefox, Safari, Edge
- Regex Flavor: ECMAScript (JavaScript) — same syntax used in Node.js, browsers, and Deno
- Flags Supported: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode)
- Max Input: Limited only by your browser's memory
Frequently Asked Questions
What is a regex tester and why do I need one?
A regex tester is a tool that runs your regular expression against sample text and shows you exactly what it matches. Writing regex without one is like coding without a debugger — you can do it, but you'll waste a lot of time guessing. The instant highlighting shows you problems the moment they happen, before your pattern ever touches production code.
Does this regex tester work with Python or PHP regex?
This tester uses JavaScript's RegExp engine (ECMAScript flavor). Most basic patterns — character classes, quantifiers, groups, lookaheads — work the same across languages. But some features differ: Python has named groups with (?P<name>) syntax, and PHP supports lookbehinds that JS didn't until recently. For 90% of patterns, what works here will work everywhere.
How do capture groups work in regex?
Parentheses () create capture groups. Whatever the pattern inside them matches gets saved separately, so you can reference it later — in replacements with $1, $2, or in code with match[1], match[2]. This tester shows each group's value in the match details section below the text panes.
What is the difference between greedy and lazy matching?
Greedy quantifiers (*, +, {n,}) grab as much text as possible and only give back characters when forced. Lazy versions (*?, +?) do the opposite — they match the minimum and expand only when needed. Try <.+> vs <.+?> on HTML tags in this tester and you'll see the difference immediately.
Is my data safe when I use this tool?
Yes. The entire tool runs in your browser using JavaScript. Your regex patterns and test strings are never sent to a server. Nothing is logged, stored, or transmitted. Close the tab and it is gone.