تخطى إلى المحتوى الرئيسي
العودة إلى المدونة
Developer • May 2, 2026 • 7 دقيقة قراءة

Regex Cheatsheet: 12 Patterns That Cover 80% of Cases

Email, URL, phone, IP, hex color, datetime, UUID — bookmark these proven patterns instead of re-inventing them.

Email (loose): ^[^\s@]+@[^\s@]+\.[^\s@]+$. Email (strict RFC 5322): too long for this excerpt — use the standard library. URL: ^https?:\/\/[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!$&'()*+,;=.]+$. US phone: ^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$. IPv4: ^(\d{1,3}\.){3}\d{1,3}$ (then validate each octet 0-255). Hex color: ^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$. UUID v4: ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$. ISO date: ^\d{4}-\d{2}-\d{2}$. Test patterns interactively with our Regex Tester.