Online Regex Tester and Debugger Tool

Test and debug regular expressions in real-time. See matches highlighted, capture groups extracted, and error messages explained.

What is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Used for string matching and manipulation, regular expressions are essential tools for text processing, validation, and parsing in virtually every programming language.

This online regex tester lets you experiment with patterns in real-time, see matches highlighted, and understand how your expressions work before implementing them in code.

Understanding Regex Flags

  • g (global): Find all matches, not just the first one.
  • i (insensitive): Case-insensitive matching.
  • m (multiline): ^ and $ match line beginnings/endings, not just string.
  • s (dotAll): Dot (.) matches newlines too.
  • u (unicode): Enable full Unicode support.
  • y (sticky): Match only at lastIndex position.

Common Regex Patterns

  • Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • Phone (US): \(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}
  • URL: https?://[^\s]+
  • IP Address: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
  • Date (YYYY-MM-DD): \d{4}-\d{2}-\d{2}
  • Hex Color: #[0-9A-Fa-f]{6}

Regex Metacharacters

  • . (dot): Match any character except newline.
  • ^ (caret): Match start of string/line.
  • $ (dollar): Match end of string/line.
  • * (asterisk): Match 0 or more of previous.
  • + (plus): Match 1 or more of previous.
  • ? (question): Match 0 or 1 of previous.
  • | (pipe): Alternation (OR).
  • [] (brackets): Character class.
  • () (parentheses): Capturing group.

Character Classes

  • \d: Digit (0-9)
  • \D: Non-digit
  • \w: Word character (a-z, A-Z, 0-9, _)
  • \W: Non-word character
  • \s: Whitespace (space, tab, newline)
  • \S: Non-whitespace

Tips for Writing Better Regex

  • Start simple and build up complexity gradually.
  • Use non-capturing groups (?:...) when you don't need to extract.
  • Be specific—avoid greedy quantifiers when possible.
  • Escape special characters with backslash.
  • Test with edge cases—empty strings, special characters, unicode.