🔍

Regex Tester & Debugger

Test and debug regular expressions with live matching

//g
Flags:
Examples:

Regex Syntax Quick Reference

Character Classes

  • . - Any character except newline
  • \\d - Digit (0-9)
  • \\w - Word character (a-z, A-Z, 0-9, _)
  • \\s - Whitespace (space, tab, newline)
  • [abc] - Any of a, b, or c
  • [^abc] - Not a, b, or c

Quantifiers

  • \* - 0 or more
  • + - 1 or more
  • ? - 0 or 1
  • {3} - Exactly 3
  • {3,5} - Between 3 and 5

Anchors

  • ^ - Start of string
  • $ - End of string
  • \\b - Word boundary

Common Regex Patterns

| Pattern | Description | Email patternEmail validation Phone patternUS Phone Zip patternUS Zip Code | URL pattern | URL Protocol |

Tips for Writing Regex

1. Start simple: Build patterns incrementally 2. Be specific: Avoid greedy patterns when possible 3. Use non-capturing groups: (?:...) when you don't need the capture 4. Escape special characters: . * + ? etc.

Frequently Asked Questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is used for string matching, validation, search and replace, and text parsing in programming.

Why do regex patterns differ between languages?

While core regex syntax is similar, different languages have variations. JavaScript lacks lookbehind support in older versions, Python has named groups with different syntax, and PHP has PCRE-specific features. This tool supports multiple flavors.

What are capturing groups?

Capturing groups, created with parentheses (), let you extract specific parts of a match. For example, (\d{3})-(\d{4}) matching 555-1234 captures "555" in group 1 and "1234" in group 2.

Related Tools

Explore other tools you might find useful:

Specialized Versions

Try our targeted calculators for specific use cases: