|
-
Feb 21st, 2006, 08:58 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] regex question
ok, i could lookup a predone answer to this at regex sites but... i really need to learn regex, not knowing at least simple expressions will continue to hold me back.
i want to validate a time format, 0:00
where the maximum is
12:00
and the minimum is
0:00
i have a combobox for the AM/PM bit
(this is actually for ASP so no i cant use a timepicker, it doesnt actually relate to asp directly though n figured id get better luck here)
i have tried a few things so far
including
[0-12]:[0-6][0-9]
[0-12]:[00-60]
[00-12]:[00-60]
with no luck... if i havnt been clear already i do not just want you to give me the expression, i would like for someone to explain what needs to be done, and how each expression is written
thanks in advance for any help.
-
Feb 21st, 2006, 09:25 AM
#2
Re: regex question
They do say history has a way of repeating itself :P
((([1-9])|(1[02]))\:([0-5][0-9])(([AM|PM|am|pm]{2,2}))
Before the semicolon, you have 1 to 9. OR, you have 10,11,12. For that, you can specify
([1-9]|[1[02])
Next, you have the colon. You'll need to escape it, so use \:
Third, you have 0 to 59.
[0-5][0-9]
Then of course, AM and PM
[AM|PM|am|pm]
-
Feb 21st, 2006, 09:30 AM
#3
Thread Starter
Frenzied Member
Re: regex question
oh! it makes alot more sense now, thanks alot
-
Feb 21st, 2006, 09:47 AM
#4
Re: [RESOLVED] regex question
Have you looked at The 30 Minute Regex Tutorial ? Good explanation there of the syntax with some examples...
-
Feb 21st, 2006, 09:57 AM
#5
Thread Starter
Frenzied Member
Re: [RESOLVED] regex question
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|