日期:2014-05-17 浏览次数:20554 次
$str = "www.asdfsfd.com,A:xiaohua,www.baidu.com,A:huanghuang,www.360buy.com,www.huahua.com,www.huanghuang.com,A:asdds,www.dd.com";
preg_match_all("/(?:(www\..*?),
------解决方案--------------------
(A\:.*?)(?=,
------解决方案--------------------
$))/",$str,$match);
$str1 = preg_replace("/,{2,}/",",",implode(",",$match[1]));
echo preg_replace("/^,/","",$str1);
echo "<br>";
$str2 =preg_replace("/(,{2,})/",",",implode(",",$match[2]));
echo preg_replace("/^,/","",$str2);
$str = "www.asdfsfd.com,A:xiaohua,www.baidu.com,A:huanghuang,www.360buy.com,www.huahua.com,www.huanghuang.com,A:asdds,www.dd.com";
preg_match_all('/(www[\w.]+),?(A:\w+)?/',$str,$m);
echo join(',',$m[1]);
echo '<br>';
echo join(',',array_diff($m[2],array('')));
$str = "www.asdfsfd.com,A:xiaohua,www.baidu.com,A:huanghuang,www.360buy.com,www.huahua.com,www.huanghuang.com,A:asdds,www.dd.com";
preg_match_all('/(www[^,]+)
------解决方案--------------------
(A:[^,]+)/', $str, $res);
$a = join(',', array_diff($res[1], array('')));
$b = join(',', array_diff($res[2], array('')));