useful regex

Date:

^(0[1-9]|1[0-2])/(0[1-9]|1\d|2\d|3[01])/(\d{4})$

mm/dd/yyyy

 

Email

^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$

xx@163.com

 

IP

((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)

255.255.255.255

 

URL

http://(/%5B\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

http://www.cnn.com

exclude some url pattern, like do not want to url containing /pages/:  ‘github.kdc.capitalone.com/pages/xxx’. This is useful in stylus chrome extension when do not want to apply style for certain urls.

^https?://github.kdc.capitalone.com((?!/pages/).)*$

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s