PHP-正则:utf8编码下,字符串去汉字和字母,只保留数字

$str = '3.33L高功率'; 
$str =  preg_replace("/[a-zA-Z][\x{4e00}-\x{9fa5}]+/u",'',$str);//替换为空
echo $str;

输出:3.33

猜你喜欢

转载自blog.csdn.net/weixin_42957379/article/details/84560745