John V wrote:
What kind of regular expression pattern is needed to check
if URL is valid? It's enought if most of cases are covered.
I have PHP 4.x.
Br
Personally, I check if the last part of the domain name (the .com, .net,
..info) part is greater than one character (to allow for country specific
domain names like ca or uk) and less than 8 characters (because I
believe there are also .museum or similar available on the net, andmore
will eventually follow).
I should (but don't) check if the last part of the domain name is
numeric (thus instead of .com that the user had entered .co1 or something).
I do check that there are at least three 'portions' to the domain name -
thus
http://www.com would fail but
www.xyz.com would pass - Or xyz.co.uk
would also pass...
And what about the protocol? Are you only refering to web http://
style addresses? If true, then check for that too... I believe there is
a maximum length for a domain name but I don't know what that is - I
have a self imposed limit of 64characters.
Lastly - your url should I believe only contain alphanumeric input, in
addition to _ (underscore) characters (though I believe you could also
have a dash, but I think this is not recommended).
Does that help you any?
randelld