编写php 正则提取以下内容中的中文:span中国 浙江省 a href=httpswwwliantucnbendiwenzhou rel=nofollow target=_blank温州市a 龙港市span
你可以使用以下正则表达式来提取中文内容:
$content = '<span>中国 浙江省 <a href="https://www.liantu.cn/bendi/wenzhou/" rel="nofollow" target="_blank">温州市</a> 龙港市</span>';
preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $content, $matches);
$chineseText = implode("", $matches[0]);
echo $chineseText;
输出结果为:
中国浙江省温州市龙港市
这样就可以提取到中文内容。
原文地址: http://www.cveoy.top/t/topic/iUXX 著作权归作者所有。请勿转载和采集!