I am looking to replace any @mention in a string with <a href="">@mention</a>
using Javascript or jQuery. I have the function from the second answer of How to replace plain URLs with links? and am simply looking to add a further replacePattern
I am looking to replace any @mention in a string with <a href="http://twitter./mention">@mention</a>
using Javascript or jQuery. I have the function from the second answer of How to replace plain URLs with links? and am simply looking to add a further replacePattern
1 Answer
Reset to default 9function replaceAtMentionsWithLinks ( text ) {
return text.replace(/@([a-z\d_]+)/ig, '<a href="http://twitter./$1">@$1</a>');
}
See it here in action: http://jsfiddle/h6HMY/