What Are Regular Expressions?
A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is used for pattern matching in text — validating email addresses, extracting phone numbers, replacing text patterns, and more. Every developer encounters regex at some point.
Basic Patterns
- \d: Any digit (0-9)
- \w: Any word character (letter, digit, underscore)
- \s: Any whitespace character
- .: Any character except newline
- *: Zero or more of the preceding element
- +: One or more of the preceding element
- ?: Zero or one of the preceding element
Real-World Examples
Email validation: ^[\w.-]+@[\w.-]+\.\w{2,}$ UK phone number: ^07\d{9}$ Postcode: ^[A-Z]{1,2}\d{1,2}[A-Z]?\s?\d[A-Z]{2}$
Use Our Tool
Try our free regex tester to test your patterns with real-time matching, replace, and split operations.