Regex Tester

Test regular expressions online for free. Real-time match highlighting, capture groups, library of common examples and match/test/replace/split methods.

Regular Expression

//g

Test Text

Advertisement

About Regular Expressions

Regular expressions (regex) are patterns used to find matches in text strings. They are powerful tools for data validation, text search and replace, and information extraction.

Basic Metacharacters

  • . - Any character (except newline)
  • * - Zero or more occurrences
  • + - One or more occurrences
  • ? - Zero or one occurrence (optional)
  • ^ - Start of string/line
  • $ - End of string/line

Character Classes

  • \d - Any digit [0-9]
  • \w - Any word character [a-zA-Z0-9_]
  • \s - Any whitespace
  • [abc] - Any character in the set
  • [^abc] - Any character not in the set

Groups and Alternation

  • (abc) - Capture group
  • (?:abc) - Non-capture group
  • a|b - Alternation (a or b)

Usage Tips

Start with simple patterns and add complexity gradually. Use the 'i' flag for case-insensitive searches. Test your regex with various test cases, including edge cases. Remember to escape special characters like . * + ? etc. when you want to use them literally.

Frequently Asked Questions

Regex is a sequence of characters that defines a search pattern. It is used for validation, search and text replacement.