Home >Backend Development >PHP Tutorial >求正则匹配字母

求正则匹配字母

WBOY
WBOYOriginal
2016-06-23 14:11:08936browse

比如:
str="我们是csdn用户!";

正则匹配如果字符串中字母个数大于2个输出ok

像这个有4个字母

正则怎么写!谢谢


回复讨论(解决方案)

手册中都有明确的说明,为什么就不看呢?

用substr扫描字符串,每段按preg_split,累积返回值到4返回true

$str="我们是csdn用户!";preg_match_all('/[a-z]/i',$str,$m);if(count($m[0]) >2) echo 'ok' ;

非常感谢!

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