Forum Moderators: coopster
I want a regular expression that tests if a full url is valid. e.g. of what I'd ideally like:
[somedomain.com...] = good
www.doman.com/filenm = good
somedomain.com/filename =good
gobbledygook = bad
If I can get the test to only answer the first one:
[somedomain.com...] = good
I'll be satisfied with that and program around the lack of http:// in the input.
There is a parse_url function, but that parse the whole thing out rather than just being a test.
BTW, I still hate regular expressions and can't wrap my mind around understanding it.
OK I looked it up, EREGI, correct?
So something like this?
$inputvar="http://www.domain.com/filnemane";
//note the single quotes around your line, is that correct?
if (eregi('^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$', $inputvar))
{
echo "'$inputvar' is a valid url";
}
else
{
echo "'$inputvar' is NOT a valid url";
}