I need a Javascript regular expression that scans a block of plain text and returns the text with the URLs as links.
This is what i have:
findLinks: function(s) {
var hlink = /s(ht|f)tp://([^ ,;:!)("'\f
v])+/g;
return (s.replace(hlink, function($0, $1, $2) {
s = $0.substring(1, $0.length);
while (s.length > 0 && s.charAt(s.length - 1) == '.') s = s.substring(0, s.length - 1);
return ' ' + s + '';
}));
}
the problem is that it will only match http://www.google.com
and NOT google.com/adsense
How could I accomplish both?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…