I don't know, how to make the subject (title) clear enough to understand. I've got something like this:
<h2>Title</h2>
<<navigation id="submenu">>
<<main level="1" asd="2">>
<<main level="1" asd="2">>
<<notmain>>asd<</notmain>>
<</navigation>>
<p><a href="..">asd</a>asdasdasd</p>
Oh no! The great rabbit is attacking us, and we are
only knights of a square table!
<h2>Here another tag can occur</h2>
<<footer>>
<<copyright id="copy">>
<</footer>>
I must find and remember (as text) objects that have two tags not one (but only the main parent). So for this example I need to output something like this:
array(
0 => '<<navigation id="submenu">><<main level="1" asd="2">><<main level="1" asd="2">><<notmain>>asd<</notmain>><</navigation>>',
1 => '<<footer>><<copyright id="copy">><</footer>>';
Spaces and white spaces, and tabs, and rest doesn't matter, as it is easy to strip it by using trim, and str_replace. The only problem is searching method.
I was trying to regex this but there are few problems.
- I'm interested in parents only. So no recursive searching inside, just outside element with '<<' '>>'and all the inside elements (don't care how they look).
- I haven't got any data of how the first word looks. It can be <>. And then return all :). I don't know, and haven't found any solution if regex can remember what it has found.
I hope that my question is clear.
I know PHP (quite well) so text solution without code, or idea will be also helpful.
If there exists a solution without regex, it will be great. There is of course a bruteforce solution, (character after character analyzing) but it needs tons of code...