私はこの美しい関数を持っていますが、正規表現に一致する項目の配列だけを返すようにカスタマイズする必要があります。結果は、#hash1234, #sweetthing,#something_notimportant
この関数を使用してこれを行う方法はありますか?
String.prototype.parseHashtag = function() {
return this.replace(/[#]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("#", "%23");
return t.link("http://search.twitter.com/search?q=" + tag);
});
};
var string = '#hash1234 this is another hash: #sweetthing and yet another #something_notimportant';
$('#result').html(string.parseHashtag());