求教一个正则问题

WBOY
Release: 2016-06-23 13:23:01
Original
825 people have browsed it

preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", “ext/plain; charset=utf-8”)
错误
preg_match(): Compilation failed: invalid range in character class at offset 7
正则不熟 求救


回复讨论(解决方案)

echo preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", "ext/plain; charset=utf-8"); //1
Copy after login

没有问题!估计是其他地方的问题

为什么你的php会报错?我用你的正则显示的是匹配成功啊。。。

<?phpheader('content-type:text/html;charset=utf-8');//$res = preg_match("/^([\.-\w]+)\/([\.-\w]+);\s(\S)*$/i", 'ext/plain; charset=utf-8');$res = preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", "ext/plain; charset=utf-8");if($res){	echo "匹配!";}else{	echo "匹配失败!";}?>
Copy after login

估计是服务器问题。debian线上正常。本地MAC和windows都有问题。无奈只能换个方法写

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!