文字列を 2 つの部分に分割します
先頭の www と A に従って文字列を 2 つの部分に分割します: 文字列を 2 つの文字列に分割します
$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"; この文字列を 2 つの文字列に分割すると、出力は $a="www.asdfsfd.com,www.baidu.com,www.360buy.com,www.huahua.com,www.huanghuang.com,www. .com";
$b ="A:小華、A:黄黄、A:asdds";
$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";<br /> preg_match_all("/(?:(www\..*?),<br><font color='#FF8000'>------解决方案--------------------</font><br>(A\:.*?)(?=,<br><font color='#FF8000'>------解决方案--------------------</font><br>$))/",$str,$match);<br /> $str1 = preg_replace("/,{2,}/",",",implode(",",$match[1]));<br /> echo preg_replace("/^,/","",$str1); <br /> echo "<br>";<br /> $str2 =preg_replace("/(,{2,})/",",",implode(",",$match[2])); <br /> 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";<br /> preg_match_all('/(www[\w.]+),?(A:\w+)?/',$str,$m);<br /> echo join(',',$m[1]);<br /> echo '<br>';<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";<br /> <br /> preg_match_all('/(www[^,]+)<br><font color='#FF8000'>------解决方案--------------------</font><br>(A:[^,]+)/', $str, $res);<br /> $a = join(',', array_diff($res[1], array('')));<br /> $b = join(',', array_diff($res[2], array('')));<br /> <br />