If your regex flavor supports lookarounds, try something like this:
(?s)<p>(?:(?!</?p>).)*</p>(?=(?:(?!</?p>).|<p>(?:(?!</?p>).)*</p>)*?</p>)
This part (?:(?!</?p>).)*
assures, that there’s no opening or closing <p
within. The positive lookahead at the end (?=
… checks for being inside </p
. See demo for trying at regex101.
Generally regex is not the means for parsing html. What regex did you try and not work?
5
solved Regexp to find only inner p tags inside the p tags