Regular Expression Library

| No Comments | No TrackBacks

When I am doing some programing, I may need the Regular Expression rule to validate the data user submit.

It is used to protect the program and save the resource of server.

To write a perfect Regular Expression Rule is not easy. You need try and try, test and test.
Until I found this site , Regular Expression Library.

I choose this one to test the URL user entered.

^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$

It works well.

Regular Expression Library has lots of expression. You always can find one suitable for your needs.


Related Articles

No TrackBacks

TrackBack URL: http://www.yinfor.com/mtcgi/mt-t-0912.cgi/2063

Leave a comment

About this Entry

This page contains a single entry by David Yin published on February 4, 2008 6:21 PM.

Gong Hei Fat Choi - Happy Chinese New Year was the previous entry in this blog.

Urgent Security Upgrade : WordPress 2.3.3 Released is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.21-en

Online Tools