To sanitise user input from a WYSIWYG editor, I'm trying to find the following strings:
<p> </p>
<p> </p>
<p></p>
This is the regular expression I'm currently using:
/\<p\>([nbsp\;]*|[\s]*|[ ]*)\<\/p\>/i
I'm quite new to RegEx, but from what I understand, this:
\<p\>: - Matches<p>exactly, then(- Matches either:[nbsp\;]*- "nbsp;" exactly, any number of times|[\s]*- or any whitespace character, any number of times|[ ]*- or " " (a space), any number of times
<\/p\>- Matches</p>exactly
However, this expression only matches <p>nbsp;</p> and not the other two.
I have also tried:
/\<p\>[nbsp\;|\s| ]*\<\/p\>/i
I am testing it using RegEx101.com (first expression, second expression)
How can I get this to work?