DeveloperTools
Text Tools

Regex Cheat Sheet: Common Patterns for Developers

A practical collection of regex patterns for email, URL, phone validation and text extraction.

Regular expressions are powerful patterns for matching and manipulating text. A small set of patterns covers most everyday tasks.

Essential Syntax

  • . — Any character except newline
  • \d — Digit [0-9]
  • \w — Word character [a-zA-Z0-9_]
  • \s — Whitespace
  • ^ / $ — Start/end of string
  • * + ? — 0+, 1+, 0-1 repetitions
  • {n,m} — Between n and m repetitions

Common Patterns

Email: [\w.-]+@[\w.-]+\.[a-zA-Z]{2,}

URL: https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w.,@?^=%&:\/~+#-]*

IPv4: (?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)

Phone (E.164): \+?[1-9]\d{1,14}

Flags

g (global), i (case-insensitive), m (multiline), s (dotall). Choose the right flags for your use case.

Frequently Asked Questions

Are these patterns compatible with all languages?
These use standard regex syntax supported by JavaScript, Python, Java, and most languages. Some may need different escape sequences.
Why not use regex for HTML?
HTML has nested structures regex can't handle. Use a proper HTML parser instead.
How do I test regex?
Use a regex tester tool that shows matches in real-time and highlights captured groups.