作者Tonnny (^~^)
看板PHP
标题[请益] preg_match
时间Wed Jun 7 01:22:27 2006
麻烦请教一下,
想要用regular expression来判断时间的格式是否符合(23:00)这样的格式
以下是设计的两个regular expression
$pattern1 = '/[0-1]?[0-9]:[0-5][0-9]/'; // 希望match(8:00,08:00,18:00)
$pattern2 = '/[2][0-3]:[0-5][0-9]/'; // 希望match(23:00)
$str = "44:00";
但 preg_match($pattern1,$str) 还是会match
====
请高手指点一下 $pattern1 该改成什麽样子呢?
Thanks~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.42.22
1F:推 LiloHuang: $pattern1 = '/^[0-1]?[0-9]:[0-5][0-9]$/'; 06/07 01:31
2F:推 Tonnny:大感谢! 06/07 01:49