2011-09-09 29 views
0

的问题,我有一个PHP的问题:有关的preg_match

当使用的preg_match,为什么#^(([a-z]{2})/)?(([a-z\-]{3,})/(([a-z\-]{3,}))?)?$#i比赛ab/cde/fgh和不匹配ab/cde

(我的意思是:

preg_match_all('#^(([a-z]{2})/)?(([a-z\-]{3,})/(([a-z\-]{3,}))?)?$#i','ab/cde/fgh',$match) 

$match = Array 
(
    [0] => ab/cde/fgd 
    [1] => ab/ 
    [2] => ab 
    [3] => cde/fgd 
    [4] => cde 
    [5] => fgd 
    [6] => fgd 
) 

preg_match_all('#^(([a-z]{2})/)?(([a-z\-]{3,})/(([a-z\-]{3,}))?)?$#i','ab/cde',$match) 
$match = Array() 
+0

请改善您的问题标题。我们已经知道这是一个问题,因为这是一个问题,我们已经知道它是关于'preg_match'的,因为它在标签中是这样说的。 –

回答

3

由于作为正则表达式被写入,则需要斜线后cde,ab/cde/应该匹配

1

[AZ - ] {3,} = 3个或更多字符