Regular Expression to validate URL format
Posted by admin
$string_url = "http://www.iwebprovider.com";
$reg_exp = "/^(http(s?):\/\/)(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/";
if(preg_match($reg_exp, $string_url) == TRUE){
echo "Valid URL Format.";
}
Back to List | Comments (3) | October 03, 2009 at 03:21 pm
Leave a Reply
Latest News (2)
iWebProvider.com No 1 at Yahoo search engine for the keyword -filipino web developer.
Posted on October 02, 2009
On Sept 6, 2009 iWebProvider.com is No. 1 at Yahoo and Google for keyword "filipino web developer".
continue reading
Launching of the updated iWebProvider.com
Posted on October 02, 2009
Now as of July 7, 2009 the launching of iWebProvider.com with its improve feature and the used of its very own CMS. It now has features like Blogs, comments on News articles and the upcoming user registration.
continue reading
Latest Comments (21)
Hi,
Its interesting for the SEO friendly URL creatin we had followed it and created using mod re-write with htaccess file you can see real PHP page converted into .html hahaha.. see here http://www.addonsolutions.com/design-a-web-2.0-website.html
Thanks
Mayur
Wise Words
"It's not about how many you have learned but how much you have utilized and mastered what you have learned."
- by: Mark Lester

3 Responses
ElenaLisvato says:
Aug 06, 2009 at 07:23 pm
Hello Guru, what entice you to post an article. This article was extremely interesting, especially since I was searching for thoughts on this subject last Thursday.
Extenze says:
Aug 13, 2009 at 12:59 pm
Hello Guru, what entice you to post an article. This article was extremely interesting, especially since I was searching for thoughts on this subject last Thursday.
Admin says:
Aug 14, 2009 at 01:35 am
Hello Extenze,
I created this code or regular expression because I want to used it for my site in validating URLs. Example of pages that uses this regular expression are my Blog, News and Contact Us page. So you are currently using it already.
Before I can't find a dynamic but simple tutorial with regular expression for validating URL. Some blogs and tutorials I have found before is to complicated, some are not so dynamic in the sense that some can’t validate URL query string.
Example it can't validate URL query string like index.php?page=blogs&id=1, it can only validate up to http://domain.com/.
So that's why I have decided to create my own regular expression for validating URL with query string.