Skip to content

Instantly share code, notes, and snippets.

@hans
Created July 29, 2008 02:50
Show Gist options
  • Save hans/3002 to your computer and use it in GitHub Desktop.
Save hans/3002 to your computer and use it in GitHub Desktop.
# l33t regular expression for matching URLs
# thanks @ Alex Payne of Twitter for providing this
# http://groups.google.com/group/twitter-development-talk/browse_thread/thread/369d81c2010f16a8#msg_eb0409891c5e18e3
%r{(<\w+.*?>|[^=!:'"/]|^)((?:https?://)|(?:www\.))([-\w]+(?:\.[-\w]+)*(?::\d+)?(?:/(?:(?:[~\w\+%-]|(?:[,.;@:][^\s$]))+)?)*(?:\?[\w\+%&=.;:-]+)?(?:\#[\w\-\.]*)?)([[:punct:]]|\s|<|$)}x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment