URL > Valid URL (RFC 3986) (Advanced) Favorite

Source: http://nadeausoftware.com/articles/2008/05/php_tip_how_parse_and_build_urls#Code

Copyright (c) 2008, David R. Nadeau, NadeauSoftware.com
BSD Licensed.
Modified by Michael Crumley (added named match groups)

Sample Matches
Text Result
/search?q=regular%20expression
Group #0
/search?q=regular%20expression
user
pass
host
port
path
/search
query
q=regular%20expression
match
http://www.google.com/
Group #0
http://www.google.com/
scheme
http
host
www.google.com
path
/
match
http://www.google.com/search?q=regular%20expression
Group #0
http://www.google.com/search?q=regular%20expression
scheme
http
host
www.google.com
path
/search
query
q=regular%20expression
match
www.google.com/
Group #0
www.google.com/
user
pass
host
port
path
www.google.com/
match
Match Groups
scheme
scheme (http, https, etc.)
user
HTTP auth user
pass
HTTP auth password
host
hostname (a.k.a. domain)
port
port number
path
path
query
querystring
fragment
fragment identifier
Notes

The URL www.example.com/ will match as a relative URL with the path "www.example.com/". This is not a bug! If the base url were http://domain.com/, this would point to http://domain.com/www.example.com/.