私はしばらくの間、次のリンク化コードを使用しています。
return str.replace(/(\s|^)(mailto\:|(news|(ht|f)tp(s?))\:\/\/\S+)/g,'$1<a href="$2" target="_blank">$2</a>')
.replace(/(\s|^)@(\w+)/g, '$1<a class="tweetmention" href="http://twitter.com/$2" target="_blank">@$2</a>')
.replace(/(\s|^)#(\w+)/g, '$1<a class="tweethash" href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');
ユーザーが画像、YouTube iframe などを追加できるシナリオができたので、これらのタグの外側の文字列にリンクをラップする必要があります。
補足: 追加できるタグを制限し、これらのタグの形式を制御できます。
助言がありますか?