fork download
  1. <?php
  2.  
  3. $re = '/(?|{([^}]*)}|\[([^]]*)])/';
  4. $str = "{A''BsCb}";
  5. $res = array();
  6. preg_match_all($re, $str, $m);
  7. foreach ($m[1] as $match) {
  8. preg_match_all('~[A-G-][^A-G]*~', $match, $tmp);
  9. $res = array_merge($tmp, $res);
  10. }
  11. print_r($res);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => A''
            [1] => Bs
            [2] => Cb
        )

)