Struts2 +验证+正则表达式

时间:2011-01-11 20:07:30

标签: java validation struts2

我想写一个正则表达式来验证这种格式的输入:

00:00 - > 24:00

它代表一天24小时。

有任何想法如何创建这样的正则表达式?

BR SC

1 个答案:

答案 0 :(得分:1)

我使用的这个很简单,很好解释,来自www.mkyong.com网站

[01]?[0-9]|2[0-3]):[0-5][0-9]

(                           #start of group #1
 [01]?[0-9]                 #  start with 0-9,1-9,00-09,10-19
 |                          #  or
 2[0-3]                     #  start with 20-23
)                           #end of group #1
 :                          #  follow by a semi colon (:)
  [0-5][0-9]                #    follow by 0..5 and 0..9, which means 00 to 59
相关问题