The Easiest Way to Save and Share Code Snippets on the web

Parse a URL into components

javascript | by: Chappell

last edit: Dec, 26th 2009 | jump to bottom

'http://user:pass@quchao.com:80/about-me/?t=091226#test'
.match(/^([^:]+):\/\/(?:([^:@]+):?([^@]*)@)?(?:([^/?#:]+):?(\d*))([^?#]*)(?:\?([^#]+))?(?:#(.+))?$/);
1134 views