Here are some common regex patterns and test cases for practice:
🔍 Common Regex Patterns
Email validation:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL matching:
^(https?://)?[^\s/$.?#].[^\s]*$
Date format (YYYY-MM-DD):
^\d{4}-\d{2}-\d{2}$
📜 Test Cases
Phone number validation
Pattern:^\+?1?[-. (]*\d{3}[-. )]*\d{3}[-. ]*\d{4}$
Password strength check
Rule: At least 8 characters with 1 uppercase, 1 lowercase, and 1 numberExtract numbers from text
Pattern:\d+
Example: "Price: $99.99" → matches99
and99
📚 Expand Reading
For deeper understanding of regex usage, check out our Regex Test Guide 📚