Im trying to add a span tag + classname around a word that contains the @ char.
My current piece of code only returns a true value if it is found, unfortunately I have no idea how to add the tag + classname. What's a proper way to do this?
var string = "hello @peter how are you?", substring = "@";
if (string.indexOf(substring) > -1){
//add span tag + classname around @peter
}
endresult should change the variable to this:
var string = "hello <span class='mentioned'>@peter</span> how are you?"