Styles

Monday, February 15, 2010

Commonly used Regular Expressions

Here is a list I put together a while back to keep for reference whenever I do validation:

First Name or Last Name

^[a-zA-Z-'\s]*$

Email

^[a-zA-Z0-9]+[a-zA-Z0-9\'._%+-]*@[a-zA-Z0-9_-]+[.]%7b1%7d[a-zA-Z0-9_-]+
[a-zA-Z0-9._-]*[a-zA-Z0-9]+$">*@[a-zA-Z0-9_-]+[.]{1}[a-zA-Z0-9_-]+
[a-zA-Z0-9._-]*[a-zA-Z0-9]+$

Phone or Mobile

^[0-9\(\)\-+\s]*$

Postcode for Australia

^[0-9]{4}$

Postcode for the US

^[0-9]{5}$

Postcode for the UK

^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]?[\s]*[0-9]{1}[a-zA-Z]{2}$

Date: Day

^([0-2]*[1-9]{1}|3[0-1]{1})$

Date: Month

^([0]*[1-9]{1}|1[0-2]{1})$

Date: Year

^(19[0-9][0-9]|20[0-9][0-9])$

CSV File with comma delimited text

,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))
There is also an incredibly useful tool that a colleague of mine, Ross Donald, built that had helped me out so much in the past:
http://www.radsoftware.com.au/regexdesigner/

1 comment :

jdn7a4ju86 said...

Use the ideas above to 온라인카지노 give yourself a good higher shot at a grand prize. Hone your recreation knowledge and prepare to hit an actual money video poker machine by working towards on-line. Take a look at at|have a look at} a number of the} hottest video poker titles on-line amongst US players.