作者:木_妍_595 | 来源:互联网 | 2023-09-12 09:16
Iamtryingtocreatearegularexpressionfortimeofaparticularday.Ithandles7amand11:34pm
I am trying to create a regular expression for time of a particular day. It handles 7am
and 11:34pm
correctly. It should be able to identify the ill-formed times. Now I have tried writing a working regular expression for the problem.
我正在尝试为某一天的某个时间创建一个正则表达式。正确处理早上7点和晚上11点34分。它应该能够识别不良的时代。现在我试着为这个问题写一个正常的表达式。
Regular Expression^(([0]?[0-9])|([1][0-2]))(\:[00-59]{2})?(am|pm){1}\b
正则表达式^(([0 - 9][0]?)|([1][0]))(\[00-59]{ 2 })?(我| pm){ 1 } \ b
The problem is that in antemeridiem, the hour part varies from 1
(or 01
) to 12
but in postmeridiem it varies from 0
(or 00
) to 12
. I am not able to deduce the regex for this situation. Kindly help.
问题是,在前梅里蒂姆,小时部分从1(或01)到12,但在后梅里蒂姆,小时部分从0(或00)到12。我无法为这种情况推断regex。请帮助。
5 个解决方案