好手!请帮忙 一个正则:字符串中包含a、b、c、d、e、f这6个字母中的任意4个或5个字母
Jun 13, 2016 pm 01:18 PM
高手!请帮忙 一个正则:字符串中包含a、b、c、d、e、f这6个字母中的任意4个或5个字母
高手!请帮忙 一个正则:字符串中包含a、b、c、d、e、f这6个字母中的任意4个或5个字母
万谢!
------解决方案--------------------
/[abcdef]{4,5}/
------解决方案--------------------
/[a-f]{4,5}/
允许重复的啊.
不允许重复的不会写正则, 只会写代码判断一下.
------解决方案--------------------
同上
------解决方案--------------------
- PHP code
$str="adcdel"; function filter($str) { preg_match('/^\S{6}$/',$str,$match); if(!empty($match[0])) preg_match('/[a-f]{4,5}/',$match[0],$matchs); return $a=isset($matchs) ? $matchs[0]:null; } $result = filter($str); if($result) { var_dump($result); echo "[[success]]"; }else{ echo "[[failed]]"; } <div class="clear"> </div>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What are the similarities and differences between __str__ and __repr__ in Python?

Python built-in type str source code analysis

How to use regular expressions to match strings in Java?

Revealing the secret of str in Go language

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题
