I am desperatley trying to get John Grubers URL recognising regexs to work properly! The simple function I wrote always returns false, even with a blatant URL in it!
I am trying to test for any url and web specific urls in 2 different functions. I am fairly new to Regexs, so this is almost certainly me!
function:
<?php
function isweburl($url)
{
return(preg_match("(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?: [^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`! ()\[\]{};:'\".,<>?«»“”‘’]))", $url));
}
function isanyurl($url)
{
echo "suspected url:$url<br>";
return(preg_match("/(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?: [^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`! ()\[\]{};:'\".,<>?«»“”‘’]))/", $url));
}
$test=isanyurl('http://www.sega.com');
var_dump($test);
echo "<br>web test:<br>";
$test=isweburl('http://www.sega.com');
var_dump($test);
?>
Thanks in advance for any help!