How to group symbols for “not in range” expression in PHP?
- <li class=”first”>list item 1</li>
- <li class=”second”>list item 2</li>
- <li class=”third”>list item 3</li>
- <li class=”fourth”>list item 4</li>
- …
I’d like to cath all li elements except one with class=”second”
This does not work:
/(<li[^(class=”second”)]+</li>)/xsU
You are probably looking for something like this:
The idea is based on using negative look-ahead assertions, grouped within capturing expressions. The complicated factors here are one of the main reasons people suggest against using regexp to parse HTML.
Explaining the RegExp: