时间:2021-07-01 10:21:17 帮助过:10人阅读
$s='BS0001/BK0003,或者 BK00006,或者 BK00006/BBM0009/DDK0003'; preg_match_all('#([^/\s]+?)/#s',$s,$m); print_r($m[1]); /* Array ( [0] => BS0001 [1] => BK00006 [2] => BBM0009 ) */
------解决方案--------------------
$str = "BS0001/BK0003,或者 BK00006,或者 BK00006/BBM0009/DDK0003"; echo preg_replace("/.*?\b([\w]{6,})[\w\/]*/i", "\\1,", $str); //BS0001,BK00006,BK00006,