[^a-zA-Z0-9u4e00-u9fa5s]小弟我用这个匹配符号,php 中preg_replace总是报错,如何破

WBOY
Release: 2016-06-13 11:59:33
Original
1156 people have browsed it

[^a-zA-Z0-9\u4e00-\u9fa5\s]我用这个匹配符号,php 中preg_replace总是报错,怎么破?
[^a-zA-Z0-9\u4e00-\u9fa5\s]  求大神赐教
------解决方案--------------------

header('Content-type: text/html;charset=utf-8');<br />$s = 'asa-de+中文123';<br />$p = '/[^a-zA-Z0-9\x{4e00}-\x{9fa5}\s]/u';<br /><br />echo preg_replace($p, '', $s); //asade中文123<br /><br />echo preg_replace('/[^\w\s]/u', '', $s); //asade中文123<br />
Copy after login


------解决方案--------------------
当目前为止,php 的正则还不支持 \u4e00 这样的表述
所以你没有错,错在 php

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!