I need a little help with a PCRE pattern I'm trying to write to use in preg_replace.
I'm trying to match any empty paragraphs. The input may contain <strong> tags, and any combination of space characters including the numeric nonbreaking space *
Here's what I have so far. It does match what I'm after, but also matches any of the individual characters within * - for instance, a 1, 6, ยก etc., which I don't want. I think it's probably pretty clunky and welcome any advice.
$pattern = '/<p>(<strong>)*[\s\W(*)]*(<\/strong>)*<\/p>/';
What I think I'm asking for is:
- a <p> tag
- possible opening <strong> tag
- 0 or more spaces, non-word characters or * characters
- possible closing <strong> tag
- closing <p> tag
Thanks in advance for any advice!