🔧

Regex Tester

Test regular expressions with real-time matching and explanations

Regular Expression

🎯 Match Results

-
Matches
-
Regex Length
-
Test Length
-
Valid
Test your regex pattern above to see matches here...

🎨 Common Regex Patterns

📧 Email Address
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Matches valid email addresses
📞 Phone Number
^\+?[1-9]\d{1,14}$
Matches international phone numbers
🌐 URL
^https?://...
Matches HTTP and HTTPS URLs
🔒 Strong Password
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)...
8+ chars with upper, lower, and digit
🎨 Hex Color
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Matches hex color codes like #fff or #ffffff
📅 Date (ISO)
^\d{4}-\d{2}-\d{2}$
Matches YYYY-MM-DD format
💳 Credit Card
^[0-9]{4}\s?[0-9]{4}\s?[0-9]{4}\s?[0-9]{4}$
16-digit credit card numbers
👤 Username
^[a-zA-Z0-9_]+$
Alphanumeric usernames with underscores

🔤 Basic Patterns

• . (dot): matches any character • * (asterisk): 0 or more of preceding • + (plus): 1 or more of preceding • ? (question): 0 or 1 of preceding • ^ (caret): start of string • $ (dollar): end of string

📚 Character Classes

• [abc]: matches a, b, or c • [a-z]: matches any lowercase letter • [A-Z]: matches any uppercase letter • [0-9]: matches any digit • \d: matches any digit (same as [0-9]) • \w: matches word characters [a-zA-Z0-9_] • \s: matches whitespace characters

🔢 Quantifiers

• {n}: exactly n times • {n,}: n or more times • {n,m}: between n and m times • *: 0 or more times (same as {0,}) • +: 1 or more times (same as {1,}) • ?: 0 or 1 time (same as {0,1})

🚩 Flags

• g (global): find all matches • i (ignore case): case-insensitive • m (multiline): ^ and $ match line breaks • s (dotall): . matches newlines • u (unicode): full unicode support • y (sticky): match from lastIndex

🎯 What are Regular Expressions?

Regular expressions (regex) are powerful patterns used to match, search, and manipulate text. They provide a concise way to describe complex text patterns and are essential tools for data validation, text processing, and search operations.

Why use regex? Regex patterns can validate user input, extract data from text, find and replace text patterns, and parse structured data. They're supported in most programming languages and text editors.

Learning tip: Start with simple patterns and gradually build complexity. Use this tester to experiment and understand how different patterns work.

🔧 Common Use Cases

  • Form validation: Validate email addresses, phone numbers, and passwords
  • Data extraction: Extract specific information from text documents
  • Text processing: Find and replace patterns in code or documents
  • Log analysis: Parse and filter log files for specific patterns
  • URL routing: Match URL patterns in web applications
  • Data cleaning: Standardise and clean messy data formats
  • Syntax highlighting: Identify code patterns for editors