当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Struts2 + Validation + RegularExpression

问题描述:

I want to write a regular expression to validate input of this format:

00:00 -> 24:00

And it represents 24 hours of a day.

Any thoughts how to create such a regular expression?

BR

SC

网友答案:

I use this one that is simple and well explained, gotten from the www.mkyong.com site

[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
分享给朋友:
您可能感兴趣的文章:
随机阅读: