π Regex Tester
Live regular expression testing with match highlighting and group capture.
How to Use This Tool
Type a regular expression in the pattern field and paste your test text in the textarea below. Matches highlight in real time and capture groups appear in the table. Use the Quick Patterns buttons to load working examples for common tasks like email, URL, and phone validation.
Enter your pattern in the regex field between the two slashes.
Set flags in the flags field: g for global, i for case-insensitive, m for multiline.
Paste your test string. Matches highlight immediately and the match count displays above.
If your pattern has capture groups, the Groups table shows each match with group values.
Greedy vs Lazy Matching and Why It Trips People Up
By default, quantifiers like *, +, and {n,m} are greedy: they match as many characters as possible. This causes problems when you want to capture content between delimiters. Consider the string <b>bold</b> and <b>more</b>. The pattern <b>.*</b> with the g flag matches the entire string from the first opening tag to the last closing tag, not two separate matches. Adding a ? after the quantifier makes it lazy: <b>.*?</b> now matches each bold section independently. Named capture groups are another feature worth building into your patterns: (?<year>\d{4})-(?<month>\d{2}) gives you named properties on each match object instead of numbered array indices, which makes the extraction code much cleaner. The flags also matter: the m flag makes ^ and $ match line boundaries rather than the full string, which is what you want when validating individual lines in a multiline input. Use this tester to verify greedy vs lazy behavior before using your pattern in production code.
Common Use Cases
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a pattern used to match character combinations in strings. Used for search, validation, and text manipulation.
What do the regex flags mean?
g=global (find all), i=case-insensitive, m=multiline (^ and $ match line start/end), s=dotAll (. matches newlines), u=unicode.
What is a capture group?
Parentheses () create a capture group. E.g. (\d{4}) captures a 4-digit year. Named groups use (?<name>...).
What does the ? quantifier do?
? means 0 or 1 occurrences. Also makes other quantifiers lazy: *? finds the shortest match.
How do I match any digit?
\d matches any digit (0-9). \w matches word characters (letters, digits, _). \s matches whitespace.