Regex Tester
Test and validate regular expressions with real-time matching and detailed results.
Results
No matches found.
About Regular Expressions
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It's a powerful tool for matching, searching, and manipulating text based on patterns.
Regular expressions are used in programming languages, text editors, and other tools to:
- Validate input formats (emails, phone numbers, etc.)
- Extract specific data from text
- Replace text based on patterns
- Split strings into components
- Find and extract information from large text datasets
Regular expressions are supported in most programming languages, including JavaScript, Python, Java, and many others, making them a universal tool for text processing.
Regular Expression Cheat Sheet
Basic Patterns
| Pattern | Description |
|---|---|
| . | Any single character (except newline) |
| \w | Word character (letter, digit, underscore) |
| \d | Digit (0-9) |
| \s | Whitespace character |
| ^ | Start of string (or line with m flag) |
| $ | End of string (or line with m flag) |
Quantifiers
| Pattern | Description |
|---|---|
| * | Zero or more occurrences |
| + | One or more occurrences |
| ? | Zero or one occurrence |
| {n} | Exactly n occurrences |
| {n,} | n or more occurrences |
| {n,m} | Between n and m occurrences |
Character Classes
| Pattern | Description |
|---|---|
| [abc] | Any character in the set |
| [^abc] | Any character not in the set |
| [a-z] | Any character in the range |
| [0-9] | Any digit (same as \d) |
Groups & Flags
| Pattern | Description |
|---|---|
| (abc) | Capturing group |
| (?:abc) | Non-capturing group |
| (?<name>abc) | Named capturing group |
| g | Global flag (find all matches) |
| i | Case-insensitive flag |
| m | Multiline flag (^ and $ match line boundaries) |
Common Examples
Email validation
Social Security Number
URL matching
IPv4 address
Time Format HH:MM 12-hour, optional leading 0
Time Format HH:MM 24-hour, optional leading 0
Time Format HH:MM:SS 24-hour
Date Format dd/mm/yyyy
Moderate Password (8+ chars, 1 uppercase, 1 lowercase, 1 number)
Complex Password (8+ chars, 1 uppercase, 1 lowercase, 1 number, 1 special)
US ZIP Codes (5 digits with optional 4-digit extension)
Visa Credit Card Numbers (13 or 16 digits starting with 4)
Common Use Cases
Data Validation
- Email address format verification
- Phone number format validation
- Password strength requirements
- Credit card number validation
Data Extraction
- Extract URLs from text
- Find hashtags in social media content
- Extract dates from documents
- Parse log files for specific events
Text Processing
- Find and replace text patterns
- Format text according to patterns
- Split text into components
- Clean and normalize text data
Web Development
- URL routing and parameter extraction
- Form validation on the client side
- Sanitize user input for security
- Extract data from HTML/XML