Javascript and PHP Regular Expression for url validation -



Javascript and PHP Regular Expression for url validation -

possible duplicate: regular look url validation (in javascript)

so i've seen many similar questions , answers can't find solution fits specific needs.

i'm terrible @ regex's , struggling simple regex next url validation.

domain.com domain.com/folder subdomain.domain.com subdomain.domain.com/folder

also validate optional http:// , http://www. super helpful. thanks!

as near can be:

/[a-z]+:\/\/(([a-z0-9][a-z0-9-]+\.)*[a-z][a-z]+|(0x[0-9a-f]+)|[0-9.]+)\/.*/

note question hasn't limited urls set of protocols, tlds or character sets.

something skype://18005551212 or gopher://localhost valid url. heck, depending on you're using browse, next might valid ways same server (though not quite same virtualhost):

http://stackoverflow.com/ http://64.34.119.12/ http://1076000524/ http://0x4022770c/

they work me in firefox.

if want farther restrictions, determine are. willing sacrifice valid protocols? interested in 1 or 2 protocols?

a more specific question more specific answer.

php javascript regex

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -