I have a string:
abc{def}ghij{kl{mn}o{pq}}r{s{t{u{v}}w}}xyz
Goal is to extract everything within brackets:
1. def
2. kl{mn}o{pq}
3. mn
4. pq
5. s{t{u{v}}w}
6. t{u{v}}w
7. u{v}
8. v
Looking for any solution, wether regex or loops.
EDIT:
Okay, since this started to getting some temper, here's what I've tried:
preg_match("/(\{[^\{]+\})+/", $str, $matches); // matches only first occurrence
preg_match_all("/(\{[^\{\}]+\})+/", $str, $matches); // this matches only the final level occurrences
And actually out of ideas how this could be achieved.
So for now, my toughest obstacle is to find all occurrences on the 1st level. This way I could recursively dig down the string and retrieve all subsets I need.