Regex Tester
Test and debug regular expressions in real-time. See matches highlighted with group information.
//g
How to Use Regex Tester
- Enter your regular expression pattern in the input field
- Toggle the flags (global, case insensitive, multiline) as needed
- Enter or paste text to test against in the test string field
- See matches highlighted in real-time with their positions
- Review match details including capture groups and named groups
What is Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for pattern matching within strings, text search and replace, input validation, and data extraction. Regular expressions are supported in most programming languages and text editors.
Common Regex Patterns
- [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - Email address
- https?://[\w.-]+(?:/[\w.-]*)? - URL (http/https)
- \+?[\d\s()-]{10,} - Phone number
- \b(?:\d{1,3}\.){3}\d{1,3}\b - IP address (IPv4)
- \d{4}-\d{2}-\d{2} - Date (YYYY-MM-DD)
- \d{2}:\d{2}(?::\d{2})? - Time (HH:MM:SS)
- #[0-9A-Fa-f]{6}\b - Hex color code
- <([a-z]+)[^>]*>.*?</\1> - HTML tag
- \b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b - Credit card number
- \b\d{5}(?:-\d{4})?\b - Postal/ZIP code (US)
- ^[a-zA-Z0-9_]{3,16}$ - Username (alphanumeric)
- ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$ - Strong password
- \s+ - Whitespace
Regex Flags Explained
- g (Global) - Find all matches rather than stopping after the first match
- i (Case Insensitive) - Makes the pattern case-insensitive (A-Z matches a-z)
- m (Multiline) - ^ and $ match the start and end of each line, not just the whole string
Example Patterns
- Match digits only
\d+ - Match words
\w+ - Match email domain
@([\w.-]+) - Extract quoted text
["'][^"']*["'] - Match file extension
\.(\w+)$
Features
- Real-time pattern matching and highlighting
- Support for global, case-insensitive, and multiline flags
- Display of all matches with their positions
- Named capture groups support
- Detailed match information with index positions
- Instant error feedback for invalid patterns
- Works entirely in your browser - no data is sent to any server