原字文字列:
$arr1=array('#]+>([^<]+)rn#i ','#
]*>#i','#?span>rn#i');
$arr2=array('$1 ', '
', '');
preg_replace($arr1, $arr2, $str);
rn は Windows 文本换行符,要注意对应文本の格式
没環境测试,自己摸索一下吧
$str1 = '
$s =<<< TXT<LI> <SPAN id=result_box lang=fr c="4" a="undefined" zd="null" closure_uid_235198886="43"> <SPAN class=hps zd="null" closure_uid_235198886="1391">la belle</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1392">courbe de</SPAN> <BR zd="null" closure_uid_235198886="1410"> <SPAN class=hps zd="null" closure_uid_235198886="1399">Parfait comme</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1400">cadeau pour votre amoureux</SPAN> <BR zd="null" closure_uid_235198886="1411"> <SPAN class=hps zd="null" closure_uid_235198886="1401">NOTE</SPAN> <SPAN zd="null" closure_uid_235198886="1402">: Laver</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1403">à la main</SPAN> </SPAN> <LI>TXT;echo strip_tags($s, '<li><br>');
$str1 = '<LI> <SPAN id=result_box lang=fr c="4" a="undefined" zd="null" closure_uid_235198886="43"> <SPAN class=hps zd="null" closure_uid_235198886="1391">la belle</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1392">courbe de</SPAN> <BR zd="null" closure_uid_235198886="1410"> <SPAN class=hps zd="null" closure_uid_235198886="1399">Parfait comme</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1400">cadeau pour votre amoureux</SPAN> <BR zd="null" closure_uid_235198886="1411"> <SPAN class=hps zd="null" closure_uid_235198886="1401">NOTE</SPAN> <SPAN zd="null" closure_uid_235198886="1402">: Laver</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1403">à la main</SPAN> </SPAN> <LI>';$reg = "/<span(.*)>|<\/span>|zd=\"(.*)\"|closure_uid_235198886=\"(.*)\"/iU";$str = preg_replace($reg, '', $str1);var_dump($str);exit;
$str1 = '<LI> <SPAN id=result_box lang=fr c="4" a="undefined" zd="null" closure_uid_235198886="43"> <SPAN class=hps zd="null" closure_uid_235198886="1391">la belle</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1392">courbe de</SPAN> <BR zd="null" closure_uid_235198886="1410"> <SPAN class=hps zd="null" closure_uid_235198886="1399">Parfait comme</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1400">cadeau pour votre amoureux</SPAN> <BR zd="null" closure_uid_235198886="1411"> <SPAN class=hps zd="null" closure_uid_235198886="1401">NOTE</SPAN> <SPAN zd="null" closure_uid_235198886="1402">: Laver</SPAN> <SPAN class=hps zd="null" closure_uid_235198886="1403">à la main</SPAN> </SPAN> <LI>';$reg = "/<span(.*)>|<\/span>|zd=\"(.*)\"|closure_uid_235198886=\"(.*)\"/iU";$str = preg_replace($reg, '', $str1);var_dump($str);exit;
$patterns = array(
'/]*>/i',
'//i ',
);
$replace = array(
'',
'',
'
',
);
echo preg_replace($patterns, $replace, $str);
これは問題ありません。