<?php
$str = '
2646,15,11,00;11,46,5,47,69,23,62,43,31,6,14,29,3,65,32,71,20,12,30,48:
2645,15,07,30;28,64,18,68,5,47,70,59,52,20,41,49,16,79,53,8,46,32,51,69:
2644,15,04,00;32,77,20,78,3,45,1,75,62,22,37,51,16,2,63,5,40,34,53,79:
2643,15,00,30;37,63,31,4,20,53,14,62,60,35,41,54,27,19,61,23,52,39,55,6 ';
preg_match_all("/([\d]+,)[\d,]+;([\d,]+:)$/m", $str, $matches);
var_export($matches);
echo preg_replace("/([\d]+,)[\d,]+;([\d,]+:)$/m","$1$2", $str);
?>
array (
  0 => 
  array (
    0 => '2646,15,11,00;11,46,5,47,69,23,62,43,31,6,14,29,3,65,32,71,20,12,30,48:',
    1 => '2645,15,07,30;28,64,18,68,5,47,70,59,52,20,41,49,16,79,53,8,46,32,51,69:',
    2 => '2644,15,04,00;32,77,20,78,3,45,1,75,62,22,37,51,16,2,63,5,40,34,53,79:',
  ),
  1 => 
  array (
    0 => '2646,',
    1 => '2645,',
    2 => '2644,',
  ),
  2 => 
  array (
    0 => '11,46,5,47,69,23,62,43,31,6,14,29,3,65,32,71,20,12,30,48:',
    1 => '28,64,18,68,5,47,70,59,52,20,41,49,16,79,53,8,46,32,51,69:',
    2 => '32,77,20,78,3,45,1,75,62,22,37,51,16,2,63,5,40,34,53,79:',
  ),
)
2646,11,46,5,47,69,23,62,43,31,6,14,29,3,65,32,71,20,12,30,48:
2645,28,64,18,68,5,47,70,59,52,20,41,49,16,79,53,8,46,32,51,69:
2644,32,77,20,78,3,45,1,75,62,22,37,51,16,2,63,5,40,34,53,79:
2643,15,00,30;37,63,31,4,20,53,14,62,60,35,41,54,27,19,61,23,52,39,55,6 

解决方案 »

  1.   

    <?php
    $str = '
    2646,15,11,00;11,46,5,47,69,23,62,43,31,6,14,29,3,65,32,71,20,12,30,48:
    2645,15,07,30;28,64,18,68,5,47,70,59,52,20,41,49,16,79,53,8,46,32,51,69:
    2644,15,04,00;32,77,20,78,3,45,1,75,62,22,37,51,16,2,63,5,40,34,53,79:
    2643,15,00,30;37,63,31,4,20,53,14,62,60,35,41,54,27,19,61,23,52,39,55,6 ';
    preg_match_all("/([\d]+,)[\d,]+;([\d,]+:?)/", $str, $matches);
    var_export($matches);
    echo preg_replace("/([\d]+,)[\d,]+;([\d,]+:?)/","$1$2", $str);
    ?>
    呃~复制错了。