Home > Backend Development > PHP Tutorial > preg_match("[u4e00-u9fa5a-zA-Z0-9-_]+","啊哈哈哈") 报错

preg_match("[u4e00-u9fa5a-zA-Z0-9-_]+","啊哈哈哈") 报错

WBOY
Release: 2016-06-06 20:28:39
Original
1557 people have browsed it

<code>preg_match("[\u4e00-\u9fa5a-zA-Z0-9\-\_]+","啊哈哈哈")  报错

preg_match(): Unknown modifier '+'</code>
Copy after login
Copy after login

回复内容:

<code>preg_match("[\u4e00-\u9fa5a-zA-Z0-9\-\_]+","啊哈哈哈")  报错

preg_match(): Unknown modifier '+'</code>
Copy after login
Copy after login

在PHP中用\x表示十六进制数据的
且必须u修正符启用了一个 PCRE 中与 Perl 不兼容的额外功能

<code>preg_match("/[\x{4e00}-\x{9fa5}a-zA-Z0-9\-_]+/u","啊哈哈哈1121234", $res);
print_r($res);</code>
Copy after login
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