html parsing - PHP, preg_match, select part of many div tags -


so need take whole div class "1" stops @ div class "1.1" ending want this:

<head> </head> <body>     <div class="1">         <p>blah blah blah</p>         <div class="1.1">             trolololol         </div>         <div class="1.2">             trolo2lolo         </div>     </div> </body> 

only this:

<div class="1">     <p>blah blah blah</p>     <div class="1.1">         trolololol     </div>     <div class="1.2">         trolo2lolo     </div> </div> 

but only:

<div class="1">     <p>blah blah blah</p>     <div class="1.1">         trolololol     </div> 

regexp not intelligent count how many tags have opened , need closed before stopping match. stops @ first occurence of </div>. try use real html parser if want access tags real tags , not strings.


Comments