This will work in code-behind, and allows the minutes and seconds to
be optional:
(0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\ [A|P][M])

This forces the minutes and seconds to be included:
(0?[1-9]|1[012])(:[0-5]\d){2}(?i:\ [A|P][M])

To you in a regex validator you need to a little less concise, since
ithe ?i: option setting causes a javascript error:
(0?[1-9]|1[012])(:[0-5]\d){2}(?i:\ [A|a|P|p][M|m])



On 6/29/05, Falls, Travis D (HTSC, CASD) <[EMAIL PROTECTED]> wrote:
> I am trying to write a regular expression and I am having some difficulties.
> I need to validate a string to see if it is a time (12 hour not 24).  I need
> it to validate all or nothing.  does anyone see anything wrong with my
> expression or a way to simplify it?
> 
> [0-2]?[0-9][:][0-5][0-9]([:][0-5][0-9])?[
> ]?([A,a][.]?[M,m][.]?)?|([P,p][.]?[M,m][.]?)?
> 
> Travis D. Falls | Consultant   RAFT.Net   IT | 860.547.4070 |
> [EMAIL PROTECTED]
> 
> 
> *************************************************************************
> PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is
> for the exclusive use of addressee and may contain proprietary,
> confidential and/or privileged information.  If you are not the intended
> recipient, any use, copying, disclosure, dissemination or distribution is
> strictly prohibited.  If you are not the intended recipient, please notify
> the sender immediately by return e-mail, delete this communication and
> destroy all copies.
> *************************************************************************
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to