Created
February 3, 2012 22:37
-
-
Save adorr/1733413 to your computer and use it in GitHub Desktop.
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
var target = target || "_blank"; | |
var re = new RegExp("\\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`!()\[\]{};:\'\".,<>?]))","g"); | |
text = "<a target=\"_blank\" href=\"http://www.google.com/\">http://www.google.com/</a>" + | |
" <a target=\"_blank\" href=\"http://www.desk.com/\">http://www.desk.com/</a>" | |
text = text.replace(re, function(str) { | |
var left = RegExp.leftContext; | |
// Chrome sometimes throws an exception when calling rightContext | |
// var right; try { right = RegExp.rightContext; } catch(e) { right = ""; }; | |
var right = RegExp.rightContext || ""; | |
if (is_auto_linked(left, right)) { | |
return str; | |
} | |
return "blah"; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment