Sunday, January 1, 2012

Regular Expressions


Here are the most commonly used regular expressions\
1.       Validating Dates : (0[1-9]|1[012])/ ([1-9]|0[1-9]|[12][0-9]|3[01])/\d{4}
2.       Zip Codes: ^\d{5}(-?\d{4})?$
3.       Phone Number : ^((\d{3}[\-\.]?\d{3}[\-\.]?\d{4})|(\d{2}[\-\.]?\d{2}[\-\.]?\d{3}[\-\.]?\d{3}))$
4.       SSN : ^\d{3}\-?\d{2}\-?\d{4}$

No comments:

Post a Comment