Reputation: 41605
I'm trying to get rid of empty paragraphs using replace
with a regex, but not having luck.
return text.replace('/(<p><\/p>)+/g', '');
I've tested the regex /(<p><\/p>)+/g
in regex101 and it seems to be ok. What am I doing wrong?
Upvotes: 4
Views: 1032
Reputation: 5412
Almost there ... but a regex in JS isn't a string
Your's
return text.replace('/(<p><\/p>)+/g', '');
Try this
return text.replace(/(<p><\/p>)+/g, '');
Upvotes: 5
Reputation: 1264
You should remove the quotes:
return text.replace(/(<p><\/p>)+/g, '');
Upvotes: 7