Home  >  Article  >  Backend Development  >  求大神帮忙写一个只有数字,字母,中文,下划线,/,空格 组成的正则表达式。!急 急 急

求大神帮忙写一个只有数字,字母,中文,下划线,/,空格 组成的正则表达式。!急 急 急

WBOY
WBOYOriginal
2016-06-23 13:53:491081browse

大腿们帮下俺这个菜鸟的忙!!谢谢


回复讨论(解决方案)

原谅我智商太低,看不懂你的问题,能把问题描述清楚吗。。。。

匹配一个名称用的,仅仅支持数字,字母,中文,下划线,空格和‘\’;

/^[\w \\]+$/u

非 utf-8 的需治安成 utf-8 后再使用

^[\u4e00-\u9fa5_a-zA-Z0-9\s\\]+$

  $aa = ' 我/1a_';  $ones =preg_match('/^[\w \/]+$/ui', $aa,$match);   var_dump($match);//输出:array(1) { [0]=> string(8) " 我/1a_" } 

把‘/’换成‘\’;应该怎么写呢

就是里面‘/’ 和 ‘\’都有

'/[\x{4e00}-\x{9fa5}\W\w\\ ]/u'

utf8下

可以了,谢谢

Statement:
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
Previous article:websocket phpNext article:catdoc如何使用?