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 as needed (global, case insensitive, multiline)
- Enter the test string you want to match against
- View matches highlighted in real-time
- Check match details including index and named groups
What is a Regular Expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regular expressions are used for pattern matching within strings, enabling powerful search, replace, and validation operations.
Common Regex Patterns
- \d - Matches any digit (0-9)
- \w - Matches any word character (a-z, A-Z, 0-9, _)
- \s - Matches any whitespace character
- . - Matches any character except newline
- ^ - Matches the start of a string
- $ - Matches the end of a string
- * - Matches 0 or more of the preceding element
- + - Matches 1 or more of the preceding element
- ? - Matches 0 or 1 of the preceding element
- [abc] - Matches any character in the brackets
- [^abc] - Matches any character not in the brackets
- (group) - Captures a group
- (?<name>group) - Named capturing group
Regex Flags Explained
- g (Global) - Find all matches rather than stopping after the first match
- i (Case Insensitive) - Match regardless of case
- m (Multiline) - ^ and $ match the start and end of each line, not just the string
Example Patterns
- Email:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL:
https?://[^\s]+ - Phone (US):
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} - IP Address:
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} - Date (YYYY-MM-DD):
\d{4}-\d{2}-\d{2}
Features
- Real-time pattern matching as you type
- Visual match highlighting in test string
- Support for global, case-insensitive, and multiline flags
- Display of match index and position
- Named capturing group support
- Invalid regex error messages
- Works entirely in your browser - no data is sent to any server