preg_match_all() is about the only way to do it accurately, in an easier manor unless you have identifying marks on either end you can easier search for like in your last example. The only problem is, the markings must match exactly somehow.. not so fun to type when coding. Which is why using a more simple syntax and using preg_match_all() works well... if you must really get the block of data inside the tags..
a lexical parser wouldn't need that much information, typically.
RegExp: Allow nested matches in a match
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
#<pre-first-key(key)post-first-key>(.*?)<pre-next-key\\1post-next-key>#is