I have this string and this regular expression. It matches hyperlinks FYI.
var str = "string https://www.pleasehelpme.com string";
var expr = "^(https:|http:|www\.)\S*";
var regex = new RegExp( expr );
If I want to replace the Url by a constant string I should do this:
var myconstantstring = "https://www.thxforyourhelpcommunity.com"
var replaced = str.replace(regex, myconstantstring);
console.log(replaced);
// displays "string https://www.thxforyourhelpcommunity.com string"
But I want to replace the url in the string by the same url, surrounded by HTML tags so the result will be as follow:
"string <a href='https://www.thxforyourhelpcommunity.com'>clic here </a> string"
Is there a way to do it by getting the matchings table returned and replace it directly into the string? Obviously, I can acheive this by separating the process with multiple little steps but this is not what I'm looking for.
Thank you all.