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://beans.com@google.com/@page/page.html?query&q=very true#fragment
http://beans.com/bees@google.com/@page/page.html?query&q=very true#fragment
http://beans.com@google.com:1000/@page/page.html?query&q=very true#fragment