Skip to content

Instantly share code, notes, and snippets.

@watzon
Created January 7, 2016 00:46
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 watzon/9c98c68a1e67899f0ce8 to your computer and use it in GitHub Desktop.
Save watzon/9c98c68a1e67899f0ce8 to your computer and use it in GitHub Desktop.
Javascript regex for capturing parts of a URL
var exp = /(?:(https|http|ftp)\:\/\/)?(?:([\w\d\_\-\.]{1,256})\.)?([\w\d\_\-]{1,256})(?:\.([\w\.]{2,6}))(?:\/([\w\d\_\-\.\:\/\\]+))?(?:\?([\w\d\_\-\=\&]+))?(?:\#([\w\d\D]+))?/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment