Skip to content

Instantly share code, notes, and snippets.

@jaredmichaelwilliams
Last active September 24, 2015 17:04
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 jaredmichaelwilliams/756b8c34d933cf5817e5 to your computer and use it in GitHub Desktop.
Save jaredmichaelwilliams/756b8c34d933cf5817e5 to your computer and use it in GitHub Desktop.
Extract URLs from text.
command with text output | grep -Eo "(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment