Regex Tester
Test regular expressions with real-time match highlighting, capture groups, and a quick reference cheat sheet.
How it works: Enter a regex pattern and test string below. Matches are highlighted in real-time as you type. Capture groups are extracted and displayed separately. Use flags to control matching behavior.
What are Regular Expressions?
Regular expressions (regex) are patterns used to match character combinations in strings. They are a powerful tool for text searching, validation, and manipulation. Every programming language supports regex — JavaScript, Python, Java, Go, PHP, and more. Mastering regex lets you validate emails, extract data from text, search and replace patterns, and parse logs efficiently.
Regex Syntax Basics
A regex pattern is built from literal characters and special metacharacters. The dot (.) matches any single character. Square brackets [abc] define a character class. Quantifiers like * (zero or more), + (one or more), and ? (zero or one) control repetition. Anchors ^ and $ match the start and end of a string. Parentheses () create capture groups that extract specific parts of a match.
Common Regex Patterns
Email validation: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. URL matching: https?://[\w.-]+(?:\.[\w.-]+)+[\w.,@?^=%&:/~+#-]*. Phone numbers: \+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}. IPv4 address: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b. These patterns can be adapted and combined for specific needs.
Common Use Cases
- Form validation (email, phone, URL, postal codes)
- Log file parsing and data extraction
- Search and replace in code editors
- Web scraping and text processing
- Input sanitization and security filtering
- Data cleaning and transformation