It seems that the solutions proposed above will fail either:
- return text in
<p>...</p> tags if it contains other tags, such as <a> , <em> , etc., or - distinguish between
<p> and <path> or - include tags with attributes such as
<p class="content">
Consider using this regex:
<p(|\s+[^>]*)>(.*?)<\/p\s*>
The resulting text will be recorded in group 2.
Obviously, this solution will not work properly when the closing tag </p> for some reason wrapped in comment tags <p>... <!--... </p>... -->
source share