Regular expression - URL validator
| From: | Wagner Garcia Campagner | Date: | Mon, 27 Aug 2007 18:57:27 +0000 |
| Subject: | Regular expression - URL validator | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261376@lists.php.net to get a copy of this message | ||
Hello,
I found this regular expression on a web site.
It is basicaly an URL validator.
I'm trying to implement this in my web site, but i receive errors.
I think this is a PERL REGEX so what should i do to make it work in php?
$valid =
(preg_match('^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9]
.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\
+&%\$#\=~_\-]+))*$', $_POST['website']));
if ($valido == 0) {
something here;
}
else {
something else here;
}
Thanks a lot in advance,
Wagner.