Parses any well-formed URI (and makes safe asumptions for commonly used bad formations), and outputs all the useful information in capture groups:
^(?:(.+?):\/\/)?(?:([^@/\n]+)@)?((?:[a-z]|[0-9]|\.)+)(?:\:([0-9]{1,5}))?([^#?\n]+)?(\?[^#\n]+)?(?:#(.+))?$
Tests:
http://[email protected]/@page/page.html?query&q=very true#fragment
http://beans.com/[email protected]/@page/page.html?query&q=very true#fragment
http://[email protected]:1000/@page/page.html?query&q=very true#fragment