12-06-2007, 04:44 AM
|
#6 (permalink)
|
|
The Contributor
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
|
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"; ?>
Last edited by Matt83 : 12-06-2007 at 09:19 AM.
|
|
|
|