- Scheme - The scheme name consists of a sequence of characters beginning with a letter and followed by any combination of letters, digits,
+
,.
, or-
. Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. The scheme name is followed by a colon:
. - Host Name - Hostname labels may contain only the ASCII letters
a
throughz
(in a case-insensitive manner), the digits0
through9
, and the-
. While a hostname may not contain other characters, such as the underscore character_
, other DNS names may contain the underscore. - Port Number - A port number is a 16-bit unsigned integer, thus ranging from
0
to65535
. - Path - If present, may optionally begin with a single forward slash
/
. It may not begin with two slash characters//
. The path is a sequence of segments (conceptually similar to directories, though not necessarily representing them) separated by a forward slash/
. - Query String -
protocol
-([\w\.\-\+]+:)
username
-([\w\d\.]+)
password
-([\w\d\.]+)
userinfo
-($username:$password)@
hostname
-([a-zA-Z0-9\.\-_]+)
port
-(\d{1,5})
host
-($hostname:$port)
authority
-($userinfo@$host)
origin
-($protocol\/{2}$authority)
pathname
-(\/(?:[a-zA-Z0-9\.\-\/\+\%]+)?)
search
-\?([a-zA-Z0-9=%\-_\.\*&]+)
hash
-#([a-zA-Z0-9\-=,&%;\/\\"'\?]+)?
(([\w\.\-\+]+:)\/{2}(([\w\d\.]+):([\w\d\.]+))@(([a-zA-Z0-9\.\-_]+):(\d{1,5})))?(\/(?:[a-zA-Z0-9\.\-\/\+\%]+)?)(?:\?([a-zA-Z0-9=%\-_\.\*&;]+))?(?:#([a-zA-Z0-9\-=,&%;\/\\"'\?]+)?)?
(([\w\.\-\+]+:)\/{2}(([\w\d\.]+):([\w\d\.]+))@(([a-zA-Z0-9\.\-_]+)(?::(\d{1,5}))?))?(\/(?:[a-zA-Z0-9\.\-\/\+\%]+)?)(?:\?([a-zA-Z0-9=%\-_\.\*&;]+))?(?:#([a-zA-Z0-9\-=,&%;\/\\"'\?]+)?)?
(([\w\.\-\+]+:)\/{2}(([\w\d\.]+):([\w\d\.]+))?@?(([a-zA-Z0-9\.\-_]+)(?::(\d{1,5}))?))?(\/(?:[a-zA-Z0-9\.\-\/\+\%]+)?)(?:\?([a-zA-Z0-9=%\-_\.\*&;]+))?(?:#([a-zA-Z0-9\-=,&%;\/\\"'\?]+)?)?
http://user:pass@www.google.com:8000/foo/bar?st=1<=10;#/koo9
http://user:pass@www.google.com/foo/bar?st=1<=10;#/koo9
http://www.google.com/foo/bar?st=1<=10;#/koo9
http://www.google.com/foo/bar?st=1<=10;
http://www.google.com/foo/bar
http://www.google.com/
/foo/bar?st=1<=10#foo
/foo/bar?st=1<=10
/foo/bar