Thursday, May 21, 2009

Regular Expressions

Phone or Fax 999-999-9999
"\d{3}\-\d{3}\-\d{4}"

Phone or Fax (999) 999-9999
"\(\d{3}\) \d{3}\-\d{4}"

Simple Email
(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})

Email blah@blah.com
"^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$"

Email blah._blah@blah.com
"^(([\w-]+\.)+[\w-]+|([a-zA-Z0-9]{1}|[\w-]{2,}))+@([-0-9a-zA-Z]+[._])+[a-zA-Z]{2,6}$"

Number 965
"\d\"

No comments:

Post a Comment