Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created December 16, 2014 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3rd-Eden/329b18e6e84bc9c5cea8 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/329b18e6e84bc9c5cea8 to your computer and use it in GitHub Desktop.
URL parsing regexp.
/^(?:(?:(([^:\/#\?]+:)?(?:(?:\/\/)(?:(?:(?:([^:@\/#\?]+)(?:\:([^:@\/#\?]*))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/.exec('https://www.mozilla.org/en-US/firefox/34.0/whatsnew/?oldversion=33.1')
var r = /^(?:(?:(([^:\/#\?]+:)?(?:(?:\/\/)(?:(?:(?:([^:@\/#\?]+)(?:\:([^:@\/#\?]*))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;
r.test('');
r.exec('https://www.mozilla.org/en-US/firefox/34.0/whatsnew/?oldversion=33.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment