如何将ereg()表达式转换为preg_match()一个? [重复]

|                                                                                                                   这个问题已经在这里有了答案:                                                      
已邀请:
        该表达式看起来不错,但是您可以简化它:
^\\d{8}\\t\\d{2}:\\d{2}:\\d{2}$
您原来的那个仍然可以使用
preg
,但是上面的那个更易于阅读和理解。一些注意事项:
[0-9]
\\d
相同 不需要
{1}
:
不需要转义     
        干得好。
$subject = \'the string i want to search through\';
$pattern = \'/^[0-9]{8}\\T{1}[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}$/\';
$matches = array();
preg_match($pattern, $subject, $matches);

print_r($matches);
    

要回复问题请先登录注册