Free Regular Expression (Regex) Tester

Test and debug regular expressions with real-time pattern matching. Perfect for developers working with text processing, validation, and data extraction.

Regex Pattern Tester

/ /
Enter your regular expression pattern without delimiters
Matches will be highlighted in real-time

Common Regex Patterns

📧 Email Validation

\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b

Matches valid email addresses

📞 Phone Numbers

\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}

US phone number formats

🌐 URL Validation

https?://...

HTTP and HTTPS URLs

🔒 Strong Password

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])...

8+ chars, upper, lower, digit, special

Understanding Regular Expressions

Regular expressions (regex) are powerful patterns used for matching character combinations in strings. They're essential for text processing, validation, search and replace operations, and data extraction.

Basic Regex Syntax

. (Dot)

Matches any single character except newline

a.c matches "abc", "axc", "a5c"

* (Asterisk)

Matches 0 or more of the preceding character

ab*c matches "ac", "abc", "abbc"

+ (Plus)

Matches 1 or more of the preceding character

ab+c matches "abc", "abbc" but not "ac"

? (Question)

Matches 0 or 1 of the preceding character

colou?r matches "color", "colour"

^ (Caret)

Matches the start of a line

^Hello matches "Hello world"

$ (Dollar)

Matches the end of a line

world$ matches "Hello world"

Character Classes

\d - Digits

Matches any digit 0-9. Same as [0-9]

\w - Word Characters

Matches letters, digits, underscore. Same as [A-Za-z0-9_]

\s - Whitespace

Matches spaces, tabs, newlines

[abc] - Character Set

Matches any character in the brackets

Quantifiers

Quantifier Meaning Example
{n} Exactly n times \d{3} matches "123"
{n,} n or more times \d{3,} matches "123", "1234"
{n,m} Between n and m times \d{3,5} matches "123" to "12345"

Common Use Cases

  • **Form validation** - Email, phone numbers, passwords
  • **Data extraction** - Parsing log files and structured text
  • **Search and replace** - Text processing and cleanup
  • **URL routing** - Web framework route matching
  • **Input sanitization** - Security and data cleaning
  • **Text parsing** - Configuration files and data formats

Regex Flags Explained

Global (g)

Find all matches in the string, not just the first one

Ignore Case (i)

Make the pattern case-insensitive

Multiline (m)

Make ^ and $ match the start/end of each line, not just the string

Frequently Asked Questions

What programming languages support regex?

Almost all modern programming languages support regex, including JavaScript, Python, Java, C#, PHP, Ruby, Go, and more. The syntax may vary slightly between languages.

How do I escape special characters in regex?

Use a backslash (\) before special characters like . * + ? ^ $ { } [ ] ( ) | \. For example, \. matches a literal dot instead of "any character".

What are capture groups?

Capture groups are parts of a regex pattern enclosed in parentheses () that "capture" the matched text for later use. They're useful for extracting specific parts of a match.

Can regex be used for parsing HTML or XML?

While possible for simple cases, regex is not recommended for parsing HTML/XML due to their complex nested structure. Use proper parsers like DOM or SAX parsers instead.