Javascript: how to replace

Dear all i have a string with multiple

</p><p><br></p><p><br></p>

inside.
How can i delete these?

Thanks for answering.

>Solution :

You can use replaceAll() function

const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';

console.log(p.replaceAll('dog', 'monkey'));
// expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?"


// global flag required when calling replaceAll with regex
const regex = /Dog/ig;
console.log(p.replaceAll(regex, 'ferret'));

Leave a Reply