[SOLVED] Regex giving me problems
Posted: Tue Sep 05, 2006 7:45 pm
I use this function to validate a URL
The problem is that it always returns false, no matter what I pass in. It should return true if $url is something like "http://www.somesite.com"
There must be a problem with the regex, but i'm not sure what it is (still in the process of learning regex).
Any ideas where the bug is?
Code: Select all
function validateURL($url) {
if(preg_match("/^http:\/\/www\.+[A-Za-z0-9]+\.a-z{2,4}/", $url))
return true;
else
return false;
}There must be a problem with the regex, but i'm not sure what it is (still in the process of learning regex).
Any ideas where the bug is?