高手!请帮忙 一个正则:字符串中包含a、b、c、d、e、f这6个字母中的任意4个或5个字母万谢!

解决方案 »

  1.   

    感谢大家!!
    1 字符串中包含a、b、c、d、e、f这6个字母中的任意4个或5个字母(任意位置)
    2 并且字符串长度不能大于6
      

  2.   


    $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]]";
    }