Regex Tester
Test and debug regular expressions online with live pattern matching. Validate email addresses, phone numbers, URLs, and custom text patterns with syntax highlighting and capture group analysis.
Flags:
Find & Replace:
Common Regex Patterns:
About Regular Expressions
What are Regular Expressions?
Regular expressions (regex or regexp) are patterns used to match character combinations in strings. They provide a powerful and flexible way to search, match, and manipulate text data across programming languages and text processing tools.
Common Regex Metacharacters
- . (dot): Matches any single character except newline
- * (asterisk): Matches zero or more of the preceding character
- + (plus): Matches one or more of the preceding character
- ? (question mark): Matches zero or one of the preceding character
- ^ (caret): Matches the start of a line
- $ (dollar): Matches the end of a line
Character Classes
- [abc]: Matches any character in the set (a, b, or c)
- [^abc]: Matches any character NOT in the set
- [a-z]: Matches any lowercase letter
- [A-Z]: Matches any uppercase letter
- [0-9]: Matches any digit
- \d: Matches any digit (equivalent to [0-9])
- \w: Matches any word character (letters, digits, underscore)
- \s: Matches any whitespace character
Quantifiers
- {n}: Matches exactly n occurrences
- {n,}: Matches n or more occurrences
- {n,m}: Matches between n and m occurrences
- *: Matches zero or more (equivalent to {0,})
- +: Matches one or more (equivalent to {1,})
- ?: Matches zero or one (equivalent to {0,1})
Regex Flags Explained
- Global (g): Find all matches, not just the first one
- Case-insensitive (i): Ignore case when matching
- Multiline (m): ^ and $ match start/end of each line
- Dotall (s): . matches newline characters
Common Questions
How do I escape special characters in regex?
Use a backslash (\) before special characters like . * + ? ^ $ | \ ( ) [ ] { } to match them literally. For example, \. matches a literal period.
What's the difference between * and + quantifiers?
The * quantifier matches zero or more occurrences, while + matches one or more occurrences. Use + when you need at least one match.
How do capture groups work?
Parentheses () create capture groups that save matched portions for later use. For example, (\d{3})-(\d{3})-(\d{4}) captures three groups from a phone number.
Why isn't my regex matching?
Common issues include: forgetting to escape special characters, case sensitivity, incorrect quantifiers, or anchor positions. Use our tester to debug your patterns step by step.