View Single Post
Old 12-06-2007, 04:44 AM   #6 (permalink)
Matt83
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

I dont think im the best qualified for giving this solution but i have created this pattern and although it is not perfect as it is It may give you a starting point for what you are trying to achieve.

Validate URL:

/^(http|https|ftp):\/\/([\w]*)\.([\w]*)\.(com|net|org|biz|info|mobi|us|cc|bz|tv|ws|name |co|me)(\.[a-z]{1,3})?$/i

Example:

PHP Code:
<?php 
$szString 
"http://www.talkPHP.com";
if (
preg_match('/^(http|https|ftp):\/\/([\w]*)\.([\w]*)\.(com|net|org|biz|info|mobi|us|cc|bz|tv|ws|name|co|me)(\.[a-z]{1,3})?$/i'$szString))
    echo 
"This is a valid URL";
?>
__________________
http://www.mattvarone.com

Last edited by Matt83 : 12-06-2007 at 09:19 AM.
Matt83 is offline  
Reply With Quote