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?
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?
You should remove the quotes:
return text.replace(/(<p><\/p>)+/g, '');
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, '');