<?php$str = "This is some random text, tag1{while this is inside a tag2{tag}}. This is some other text tag2{also with a tag tag3{inside} of it}."; $re = "/\\b(\\w+)(?={((?:[^{}]+|{(?2)})*)})/";preg_match_all($re, $str, $m); echo "* Tag names:\n";print_r($m[1]);echo "* Tag content:\n";print_r($m[2]);?>
Standard input is empty
* Tag names: Array ( [0] => tag1 [1] => tag2 [2] => tag2 [3] => tag3 ) * Tag content: Array ( [0] => while this is inside a tag2{tag} [1] => tag [2] => also with a tag tag3{inside} of it [3] => inside )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!