tags:

views:

75

answers:

1

i need a url regex which validates the url string without http://www. or https://www.

any ideas?

+1  A: 

It would probably be a good idea to keep the www's intact in order to preserve the sub-domain. A regex pattern like this:

^([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$

would match a URL that is not prefixed by a protocol (http://,https://,ftp://,etc).

sigint
thank you! as i said i'm not removing the www. it would be appended to the url which the user enters in the textbox.
fuz3d
Joel Etherton
@fusion What if `example.com` doesn't have a `www` subdomain? You shouldn't blindly prepend the `www`'s. @Joel Etherton You are correct, this regex pattern would be VERY liberal when dealing with (what should be) GET parameters.
sigint