Developer

Regex for beginners: the only 10 patterns you need

Match emails, phone numbers, dates, URLs, and 6 more common patterns — with explanations you’ll remember.

Elevatools Team·2026-01-15· 3 min
Share

The core syntax

  • . any character
  • * 0 or more
  • + 1 or more
  • ? optional
  • \d digit, \w word char, \s whitespace
  • [abc] character class
  • ^ start, $ end
  • (...) capture group

10 most-used patterns

  1. Email: [\w.-]+@[\w.-]+\.\w+
  2. Phone (Indian): (?:\+91|0)?[6-9]\d{9}
  3. Date YYYY-MM-DD: \d{4}-\d{2}-\d{2}
  4. URL: https?://[^\s]+
  5. PAN: [A-Z]{5}\d{4}[A-Z]
  6. GSTIN: \d{2}[A-Z]{5}\d{4}[A-Z][A-Z\d]Z[A-Z\d]
  7. IPv4: \d{1,3}(?:\.\d{1,3}){3}
  8. Hex color: #[0-9a-fA-F]{6}
  9. Whitespace cleanup: \s+
  10. Trim: ^\s+|\s+$

Use Elevatools Regex Generator to convert plain English to regex instantly.

Related reads