I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty P Tags from the output. I have tried the following RegEx with no success:
replace($string,"<p>[\s{2,}]*</p>","")
The output from the Stylesheet at the moment looks like below:
<p>Some Text!</p>
<p></p>
<p>Some Text!</p>
<p> </p>
<p> </p>
<p>Some Text!</p>
From this I want the output to strip the P tags that have just 1 or more spaces within them, so it would look like this:
<p>Some Text!</p>
<p>Some Text!</p>
<p>Some Text!</p>
Thanks
🙂
I would suggest using next regular expression:
/<p>(|\s+)<\/p>/Explanation:
You can see it in action by the link http://regexr.com?31f6a (be sure to switch to ‘Replace’ mode and set replacement text to nothing).
Update
Actually, the
(|\s)expression and\s*does the same thing (Thanks to Rawling), so you can write the main expression as/<p>\s*<\/p>/.