← Imperial Products / Tools / Regex Tester

Regex Tester & Debugger

Test regular expressions in real time. See matches highlighted and capture groups extracted. 100% client-side.

/ /
0 matches
Test String
Matches (highlighted)

Common Patterns (click to use)

Email[a-zA-Z0-9._%+-]+@...
URLhttps?://...
IPv4\\b\\d{1,3}\\.\\d{1,3}...
Credit Card\\b\\d{4}[- ]?\\d{4}...
Strong Password^(?=.*[a-z])(?=.*[A-Z])...
US Phone(\\d{3})[- ]?(\\d{3})...
Hex Color#([0-9a-fA-F]{3}){1,2}
US Zip Code\\b\\d{5}(-\\d{4})?\\b

More Free Developer Tools

How to Use This Regex Tester

Type or paste your regular expression into the pattern field between the two forward slashes. Add flags in the box to the right — the most common are g (global, find all matches), i (case-insensitive), and m (multiline, makes ^ and $ match line boundaries). Then paste your test string in the left panel — matches are highlighted in amber in the right panel instantly as you type.

If your pattern contains capture groups using parentheses, a table below the editor will show each group's extracted value for every match. This is especially useful when you need to pull specific parts out of a string, such as extracting the domain from an email address or the year from a date.

Common Regex Patterns Reference

The clickable pattern library above covers the most frequently needed patterns, but here are a few more worth knowing. To match any digit, use \d; for any word character (letter, digit, underscore), use \w; for whitespace, use \s. The dot . matches any character except a newline. Anchors ^ and $ assert the start and end of a line. Quantifiers like + (one or more), * (zero or more), and {2,5} (between 2 and 5 times) control repetition.

When to Use Regular Expressions

Regex excels at three tasks: validation (does this string match a format?), extraction (pull specific parts out of a string), and replacement (find and replace with complex rules). Common real-world uses include validating form inputs like emails, phone numbers, and postal codes; scraping structured data from log files or HTML; and performing bulk find-and-replace operations in code editors. Regex is available natively in JavaScript, Python, Ruby, Go, Java, PHP, and virtually every other language.

Testing Tips

Build your pattern incrementally — start with the simplest possible match and add complexity one piece at a time. Always test against both valid inputs you want to match and invalid inputs you want to reject. Watch out for catastrophic backtracking: deeply nested quantifiers like (a+)+ can cause exponential execution time on certain inputs. The execution time shown below the pattern field will alert you to patterns that run slowly.