I have this text @abc some text here
. How can I make it into <a href="some_url">@abc</a> some text here
using javascript? any library to do that?
CodePudding user response:
Use a regex replacement:
var input = "@abc some text here";
var output = input.replace(/(@\S )/, "<a href=\"some_url\">$1</a>");
console.log(output);