I want to check some string containing HTML to see if it will contain any <li>
elements, and filter out every element except for the <li>
elements.
For example,
<li>foo</li><p><em>bar</em><em style="color: rgb(161, 0, 0);">fiddle</em></p><p><em class="ql-font-couriernew" style="color: rgb(61, 20, 102);">dog</em></p>
Would become
<li>foo</li>barfiddledog
I can figure out how to capture just <li>
elements, or all HTML elements, but I can't figure out how to capture only elements that are not <li>
.
I am using (<\/?[^(li)]>)+
, but this seems to only filter out the <p>
and </p>
tags.