Test and validate regular expressions online. Debug regex patterns, find matches, and learn regex syntax with our professional testing tool.
Pattern: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b
Use Case: Extract all email addresses from text content, useful for contact information mining.
Sample Text: "Contact us at support@company.com or sales@business.org"
Pattern: (\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
Use Case: Find and standardize phone numbers in various formats.
Sample Text: "Call (555) 123-4567 or +1-555.987.6543"
Pattern: https?://(?:[-\w.])+(?:\:[0-9]+)?(?:/(?:[\w/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?
Use Case: Extract all URLs from web content or documents.
Sample Text: "Visit https://example.com or http://subdomain.site.org/path"
Pattern: \b(?:\d{4}[-\s]?){3}\d{4}\b
Use Case: Identify credit card numbers in text (for security scanning).
Sample Text: "Card: 1234-5678-9012-3456 or 1234567890123456"
Pattern: (\d{1,2})/(\d{1,2})/(\d{4})
Use Case: Convert date formats from MM/DD/YYYY to other formats.
Sample Text: "Events: 12/25/2024, 01/01/2025, 07/04/2024"
Pattern: <[^>]*>
Use Case: Strip HTML tags from content to get plain text.
Sample Text: "<p>Hello <strong>world</strong>!</p>"
Pattern: \$\d+(?:\.\d{2})?
Use Case: Extract price information from product descriptions.
Sample Text: "Product costs $29.99, sale price $19.99, shipping $5.00"
Pattern: ^-?\d+(\.\d+)?$
Use Case: Validate numeric input including decimals and negative numbers.
Sample Text: "Values: 123, -45.67, 0.123, -999"
.
- Any character except newline\d
- Any digit (0-9)\D
- Any non-digit\w
- Any word character (a-z, A-Z, 0-9, _)\W
- Any non-word character\s
- Any whitespace character\S
- Any non-whitespace character[abc]
- Any character in the set[^abc]
- Any character not in the set[a-z]
- Any character in the range*
- 0 or more occurrences+
- 1 or more occurrences?
- 0 or 1 occurrence{n}
- Exactly n occurrences{n,}
- n or more occurrences{n,m}
- Between n and m occurrences*?
- Non-greedy 0 or more+?
- Non-greedy 1 or more??
- Non-greedy 0 or 1^
- Start of string/line$
- End of string/line\b
- Word boundary\B
- Non-word boundary\A
- Start of string\Z
- End of string(abc)
- Capturing group(?:abc)
- Non-capturing group(?=abc)
- Positive lookahead(?!abc)
- Negative lookahead(?<=abc)
- Positive lookbehind(? - Negative lookbehind
\1
- Back reference to group 1|
- Alternation (OR)\
- Escape special character\n
- Newline\r
- Carriage return\t
- Tab\0
- Null character\f
- Form feed\v
- Vertical tabg
- Global: Find all matchesi
- Ignore case: Case-insensitive matchingm
- Multiline: ^ and $ match line breakss
- Dotall: . matches newlinesu
- Unicode: Full unicode supporty
- Sticky: Match from lastIndexRegular expressions (regex) are powerful patterns used to match character combinations in strings. They're essential tools for text processing, validation, and data extraction in programming and data analysis.
A regex pattern consists of literal characters and special metacharacters that define the search criteria:
/pattern/flags
Example: /hello/i
matches "hello", "Hello", "HELLO" (case-insensitive)
Step 1: Start with literal characters
cat
This matches the exact string "cat"
Step 2: Add character classes
[Cc]at
This matches "cat" or "Cat"
Step 3: Use quantifiers
[Cc]ats?
This matches "cat", "Cat", "cats", or "Cats"
(a+)+
*?
vs *