Hello world!
I am here

" I want to get the output result after replaced: "

Hello world! I am here

" How " /> Hello world!
I am here

" I want to get the output result after replaced: "

Hello world! I am here

" How " /> Hello world!
I am here

" I want to get the output result after replaced: "

Hello world! I am here

" How "/>

How to replace <br /> tag name to white space in sanitize-html JavaScript?

924 Views Asked by At

I have a string of HTML like:

"<p>Hello world!<br/>I am here</p>"

I want to get the output result after replaced:

"<p>Hello world! I am here</p>"

How I can do it with sanitize-html package?

1

There are 1 best solutions below

1
NodeJSDeveloper On

Source: replaceAll

const result = 'lorem<br />ipsum<br />hello'.replaceAll('<br />', ' ');
// result = 'lorem ipsum hello';