php正则提取中文
<?php
$str = "用户名123阿斯蒂芬dfsdf阿道夫";
//把结果放在$chinese中
//GBK/GB2312使用:
preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $str, $chinese);
//UTF-8 使用:
//preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $str, $chinese);
print_r($chinese);
$count = count($chinese[0]);
for ($x = 0; $x < $count; $x++) {
echo $chinese[0][$x];
}
?>