21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$str = 'a,b,21,3efw,123123,dcf3,df,23,2ter,13232,asdaa,b,sfs21,3efadw,123123,dcf3,dadf,23,2ter,13232,asadd,ff';
$reg = '/(?:[^,]*,){5}[^,]{0,3}|(?:[^,]*,?){0,4}$/im';
$matches = array();
preg_match_all($reg, $str, $matches);
print_r($matches);
<?php
$str = 'a,b,21,3efw,123123,dcf3,df,23,2ter,13232,as,dcf3,df,23,2ter,13232,asd';
$reg = '/(?:[^,]*,){5}[^,]{0,3}/im';
$matches = array();
preg_match_all($reg, $str, $matches);
print_r($matches);