Created
July 16, 2011 17:33
-
-
Save jmdfm/1086574 to your computer and use it in GitHub Desktop.
Gruber's Ultimate URL RegExp for Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i | |
See http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
Be sure to add: | |
# coding: utf-8 | |
At the very top of your Ruby file where you use the above expression. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment