deftools.io Developer Tools

Regex Tester

Test and debug regular expressions against sample text — live match highlighting, capture group inspection, replace mode, common pattern library.

/ /

About this tool

A regular expression (regex) is a compact pattern language for matching, extracting, and replacing text. This tester runs your pattern against a sample string in real time, highlights every match, lists numbered and named capture groups in a table, and supports a replace mode where you can substitute matches using $1, $2 for captured groups.

Common use cases: validating form input (emails, phone numbers), extracting data from logs, transforming text in bulk, or learning how a regex engine behaves. Example: pattern (\w+)@(\w+\.\w+) on the default sample produces three email matches with two capture groups each (local part and domain). Switch to Replace with $1 [at] $2 to mask addresses as user [at] example.com.

Pick a preset from the dropdown for ready-made patterns (email, URL, IPv4, UUID, hex color, strong password, and more), toggle flags with checkboxes, and copy a shareable link that encodes your pattern, flags, and test string.

FAQ

What does the "g" flag do?

The global flag (g) tells the regex engine to find every match in the string, not just the first one. Without it, only the first match is returned. In Replace mode, only with g does every occurrence get replaced.

How do capture groups work?

Parentheses in a pattern create capture groups. The full match is group 0, then each pair of parentheses becomes $1, $2, and so on. Named groups like (?<year>d{4}) are referenced by name. The Match Details table shows every group value per match.

Why is my pattern matching too much?

The most common cause is greedy quantifiers. Adding ? after a quantifier makes it lazy — '.*?' matches as few characters as possible instead of as many. Use word boundaries () to avoid matching inside larger words.

Can I share my test case?

Yes. The tool encodes your pattern, flags, and test string into the URL hash automatically. Click "Copy share link" and anyone who opens it sees the same setup. The link works for any reasonable pattern length.

How do I step through matches one by one?

When there are two or more matches, Prev/Next buttons appear next to the highlight label. You can also press ← and → (when not focused on an input) to cycle through matches. The active match gets a yellow highlight and the corresponding row in the details table is tinted. Click any row in the table to jump straight to that match.

How is this different from the Regex Explainer?

This tool runs your regex against sample text and shows live matches, captures, and replacements. If you just want to understand what a regex means without running it, try the Regex Explainer which decodes each token into plain English.

More developer tools

Copied!