3👍
✅
Use a regex replacement:
var input = "@abc some text here";
var output = input.replace(/(@\S+)/, "<a href=\"some_url\">$1</a>");
console.log(output);
Source:stackexchange.com