<?php $test_string = <<<TEST[startA]this is the first group [startB] blabla[end][end][startA]this is the second group [startB] blabla[end][end][startA]this is the second group [startB] blabla[end][end]TEST;preg_match_all('#\[startA](.+?)\[end]\s*(?=\[startA]|$)#s', $test_string, $matches);var_dump($matches[1]);
Standard input is empty
array(3) { [0]=> string(49) " this is the first group [startB] blabla [end] " [1]=> string(50) " this is the second group [startB] blabla [end] " [2]=> string(50) " this is the second group [startB] blabla [end] " }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!