I have an HTML string containing names:
<div class=\"ExternalClassBE95E28C1751447DB985774141C7FE9C\"><p>Tina Schmelz<br></p><p>Sascha Balke<br></p></div>
And, I would like to remove all html tags and put '&' between names but not at the end of last one like:
Not desired: Tina Schmelz & Sascha Balke &
Desired: Tina Schmelz & Sascha Balke
I used regex and string replace property.
I could do it by using replace all for <br> tags with ' & ' and then removed all html tags by using this codes:
let mytext = '<div class=\"ExternalClassBE95E28C1751447DB985774141C7FE9C\"><p>Tina Schmelz<br></p><p>Sascha Balke<br></p></div>';
mytext = mytext.replaceAll(/<br>/gi, ' & ');
mytext = mytext.replaceAll(/<.*?>/gi, '');
console.log(mytext)
My question: how can I remove last ' & '? Or, does anyone knows better RegEx for it to complete everything in one line? :)