14,976,254 members
1.00/5 (1 vote)
See more:
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
Posted
Updated 13-Mar-21 5:16am
v2
Dalek Dave 7-Sep-10 4:59am

Edited for Readability, Grammar and Code Block removal.

## Solution 1

What have you attempted so far?

avishekrc 7-Sep-10 5:34am

Hi,
I have got RegEx for time:
^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])\$
And for CSV:
[0-9]+(,[0-9]+)*
But I need to combine them.

## Solution 2

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!
Hiren solanki 6-Oct-10 1:57am

Member 15099248 13-Mar-21 11:16am

@avishekrc Hey need help to create regex for 10:00AM-11:00AM or 10:00AM-11:00AM, 12:00PM-2:00PM… time range can be single or multiple