Mark13426
Mark13426

Reputation: 2639

Remove   between p tags

Using regex in JavaScript, how would I replace the following tags with an empty string?

<p>&nbsp;</p>
<p>&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;</p>
.
..
...

There could be any number of &nbsp; entities between the p tags.

Upvotes: 0

Views: 3317

Answers (2)

jasonslyvia
jasonslyvia

Reputation: 2535

"your content filled with &nbsp".replace(/(&nbsp;)/gi, '');

Upvotes: 2

BaBL86
BaBL86

Reputation: 2622

This code. you need:

var x = '<p>&nbsp;&nbsp;</p>';
x.replace(/<p>(&nbsp;)+<\/p>/i, '');

Upvotes: 1

Related Questions