Home > Backend Development > PHP Tutorial > 求一正则,该如何解决

求一正则,该如何解决

WBOY
Release: 2016-06-13 10:34:52
Original
1053 people have browsed it

求一正则
可以匹配键盘上所有可见的字符,包括@#¥……&×()等等,反正键盘上看得到的 都匹配,但不包括中文,俄文之类的。。

------解决方案--------------------

PHP code
$str='~!@#$%^&*()_+0124JHB"你好啊ghjk';preg_match_all('/[[:punct:]\w ]/i',$str,$m);print_r($m);<br><font color="#e78608">------解决方案--------------------</font><br>\w是字母数字下划线<br><font color="#e78608">------解决方案--------------------</font><br>你的环境有点异常 可能是版本、编码方面的问题<br>正常情况下\w不可能匹配到中文的呀<br>实在不行用 [[:punct:]a-z0-9_]/i 吧<br><font color="#e78608">------解决方案--------------------</font><br>的确, 你不会是unicode文件吧.<div class="clear">
                 
              
              
        
            </div>
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