逗号分隔时间值的正则表达式 [英] Regular expression for comma separated Time values

查看:185
本文介绍了逗号分隔时间值的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的要求如下:
我想要一个文本框,它将接受CSV值,并且这些值可以是一天中的任何时间,即.在一个文本框中,我可以输入多个时钟时间,以逗号分隔.小时和分钟用冒号分隔,不需要秒.

如果是上午或下午可以关联,这将是很好的[0-12基础],否则0-24基础就可以了.

接受的输入:1:00、12:45、23:59、11:34
在此先感谢您.

Hi,

My requirement is as follows:
I want a text box which will accept CSV values and the values can be any time of a day, ie. in one text box I can enter multiple clock times separated by comma. Hour and Minutes will be separated by a colon, Seconds not required.

If a.m. or p.m. can be associated it would be great [0-12 basis], otherwise 0-24 basis will be fine.

Accepted Inputs: 1:00, 12:45, 23:59, 11:34
Thanks in advance.

推荐答案

您到目前为止尝试了什么?

显示我们的代码.
What have you attempted so far?

Show us your code.


从ASP.Net论坛获得答案,这里是:
输入时间:1:00 AM,12:45 pm,03:59am,11:34 aM,...
RegEx:(([[0]?[1-9] | [0-1] [0-2]):([0-5] [0-9])()?((AM | am | aM | Am | PM | pm | pM | Pm))+((,)()?(([[0]?[1-9] | [0-1] [0-2]):: [[0-5] [0- 9])()?((AM | am | aM | Am | PM | pm | pM | Pm))+)*
-------------
时间输入:1:15,15:45,23:59,00:34,02:05
正则表达式:(([[0]?[0-9] | [1] [0-9] | [2] [0-3]):([0-5] [0-9]))+((, )()?(([[0]?[0-9] | [1] [0-9] | [2] [0-3]):([[0-5] [0-9]))+) *
-------------
时间输入:1:15,03:59 am,15:45,23:59,00:34,11:34 aM,02:05,1:00 AM,12:45 pm
RegEx:((([[0]?[1-9] | [0-1] [0-2]):([0-5] [0-9])()?((AM | am | aM | Am | PM | pm | pM | Pm))|(([[0]?[0-9] | [1] [0-9] | [2] [0-3]):([0-5] [0 -9]))))+((,)()?((([[0]?[1-9] | [0-1] [0-2]):([[0-5] [0-9] )()?((AM | am | aM | Am | PM | pm | pM | Pm))|(([0]→[0-9] | [1] [0-9] | [2] [0- 3]):([[0-5] [0-9])))+)*

-------------
希望对别人有帮助!
Got the answer from ASP.Net forum,here it is:
Time Input : 1:00 AM, 12:45pm,03:59am,11:34 aM, ...
RegEx : (([0]?[1-9]|[0-1][0-2]):([0-5][0-9])( )?(AM|am|aM|Am|PM|pm|pM|Pm))+((,)( )?(([0]?[1-9]|[0-1][0-2]):([0-5][0-9])( )?(AM|am|aM|Am|PM|pm|pM|Pm))+)*
-------------
Time Input : 1:15,15:45, 23:59,00:34, 02:05
RegEx : (([0]?[0-9]|[1][0-9]|[2][0-3]):([0-5][0-9]))+((,)( )?(([0]?[0-9]|[1][0-9]|[2][0-3]):([0-5][0-9]))+)*
-------------
Time Input : 1:15,03:59am,15:45, 23:59,00:34, 11:34 aM,02:05, 1:00 AM, 12:45pm
RegEx : ((([0]?[1-9]|[0-1][0-2]):([0-5][0-9])( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|[1][0-9]|[2][0-3]):([0-5][0-9])))+((,)( )?((([0]?[1-9]|[0-1][0-2]):([0-5][0-9])( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|[1][0-9]|[2][0-3]):([0-5][0-9])))+)*

-------------
Hope it helps someone else!


这篇关于逗号分隔时间值的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆