Skip to main content

Go Premium

No ads • Priority support • Export to PDF

100% Private

Regex Tester

Test and debug regular expressions with real-time matching

//

Matches (0)

Enter a pattern to find matches

Common Patterns

Quick Reference

. - Any character

\d - Digit [0-9]

\w - Word char [a-zA-Z0-9_]

\s - Whitespace

* - 0 or more

+ - 1 or more

? - 0 or 1

^ - Start of string

$ - End of string

Regex Tester - Test Regular Expressions Online

Test and debug your regular expressions in real-time with our free online regex tester. See matches highlighted instantly as you type, with support for all JavaScript regex features and common patterns library.

What are Regular Expressions?

Regular expressions (regex) are patterns used to match character combinations in strings. They're an essential tool for developers, used for validation, search and replace, parsing, and data extraction across virtually every programming language.

Common Regex Patterns

  • Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • URL: https?:\/\/[\w\-]+(\.[\w\-]+)+[\w\-.,@?^=%&:/~+#]*
  • Phone (US): \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
  • IP Address: \b(?:\d{1,3}\.)+\d{1,3}\b
  • Date (YYYY-MM-DD): \d{4}-\d{2}-\d{2}

Regex Flags Explained

  • g (Global): Find all matches, not just the first one
  • i (Case Insensitive): Match regardless of uppercase/lowercase
  • m (Multiline): ^ and $ match start/end of each line, not just the string
  • s (Dotall): Allow . to match newline characters

Essential Regex Metacharacters

  • . - Matches any single character (except newline)
  • \d - Matches any digit [0-9]
  • \w - Matches word characters [a-zA-Z0-9_]
  • \s - Matches whitespace (space, tab, newline)
  • ^ - Matches start of string
  • $ - Matches end of string
  • * - Matches 0 or more of the preceding element
  • + - Matches 1 or more of the preceding element
  • ? - Matches 0 or 1 of the preceding element

Regex Best Practices

  • Start simple and add complexity as needed
  • Use character classes [abc] instead of alternation (a|b|c) when possible
  • Anchor your patterns with ^ and $ when matching entire strings
  • Use non-capturing groups (?:...) when you don't need the match
  • Be careful with greedy quantifiers (*,+) - use lazy versions (*?,+?) when appropriate
  • Test edge cases: empty strings, special characters, very long inputs

Common Regex Mistakes

  • Forgetting to escape special characters like . * + ? [ ] ( )
  • Using greedy matching when lazy matching is needed
  • Not accounting for optional whitespace
  • Overly complex patterns that are hard to maintain
Sponsored

Premium Partner

Check out this recommended service.

Privacy First

Unlimited history • Encrypted backups