missing-score
04-11-2003, 04:47 PM
Right I have this piece of code which I use to validate web addresses.
$erg = "([a-zA-Z0-9]+){0,1}:(\\/){0,3}(www\.)?([a-zA-Z0-9\\-_\\@]+\\.)+([a-zA-Z0-9]+[\\.]?[a-zA-Z0-9]?){1}([\\/]?[\\.]?[a-zA-Z0-9]?[\\?]?){0,}";
if(eregi($erg,$myurl) == 1)
{
$myurl = eregi_replace($erg,'<a href="'.$myurl.'">'.$myurl.'</a>',$myurl);
echo $myurl;
}
I make it print out the URL when it is done. It works fine, until you put anything in the main address with a hyphen or equals (-,=) sign in it.
It then prints the link, plus everything after the hyphen. Can anyone tell me why?
$erg = "([a-zA-Z0-9]+){0,1}:(\\/){0,3}(www\.)?([a-zA-Z0-9\\-_\\@]+\\.)+([a-zA-Z0-9]+[\\.]?[a-zA-Z0-9]?){1}([\\/]?[\\.]?[a-zA-Z0-9]?[\\?]?){0,}";
if(eregi($erg,$myurl) == 1)
{
$myurl = eregi_replace($erg,'<a href="'.$myurl.'">'.$myurl.'</a>',$myurl);
echo $myurl;
}
I make it print out the URL when it is done. It works fine, until you put anything in the main address with a hyphen or equals (-,=) sign in it.
It then prints the link, plus everything after the hyphen. Can anyone tell me why?