有这么一种情况,每行字符是这种格式的:
{内容1}{内容2}
内容被包含在{}中,每行有不等的{}。
请给个程序,能把这些内容取出,放入一个数组中

解决方案 »

  1.   

      $str="{123}{456}{789}{012}{245}{754}";
      $pre="/{.*[^}]}/iUs";
      preg_match_all($pre,$str,$content);
      print_r($content);
      

  2.   


    $str = '{123}{456}{789}{012}{245}{754}';
    preg_match_all('/\{(\d+)\}/U', $str, $matches);
    print_r($matches[1]);
    /**
    输出结果:
    Array ( [0] => 123 [1] => 456 [2] => 789 [3] => 012 [4] => 245 [5] => 754 ) 
    */
      

  3.   

    $pre="/{.*[^}]}/iUs";// 替换为/{[^{]*}/Us更易理解