This article will gives u the certain regular expressions that will be used normally in all the applications.
Numeric Validation ----
1. ‘\d+’ – Only numbers (0-9) can be entered in the field. 2. ‘^[0-9]*$’ – Only numbers (0-9) can be entered in the field. 3. ‘^9[0-9]*$ - Only numbers (0-9) can be entered in the field.The number will always start with 9. 4. ‘^\d{1,4}$’ – Numbers may be of length starting from single digit to fourdigits. 5. [0-9]{5} – Only numbers are allowed.The maxlength for the number will be five digits. 6. ‘[+][0-9]{1,4}[-][0-9]{1,6}[-][0-9]{1,15}’ – Numbers will be in the format of +44-20-76297988 +44(Maxlength will be from singledigit to fourdigits)-20(Maxlength will be from singledigit to sixdigits)-76297988(Maxlength will be from singledigit to fifteen digits)
Email Address Validation ----
Expression 1 ----
‘[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?’ Expression 2 -----
^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$
String Validation ---- 1. ‘^[\w+\s]+$’ – Any characters with whitespace will be allowed
2. ‘^[\w,-,'.']+$’ – Characters and special characters like ‘–‘ and ‘.’ are allowed
|
| Author: Devendra 04 Jul 2009 | Member Level: Gold Points : 1 |
Dear,
Thanks for valuable help. We can use it in future and you can make it more wide like Image Upload Control Validations (For File extensions) Like for Photo u can use /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP)$/
And Many More
|