Results 1 to 5 of 5

Thread: [RESOLVED] regex question

  1. #1

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Resolved [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.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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]

  3. #3

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: regex question

    oh! it makes alot more sense now, thanks alot

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: [RESOLVED] regex question

    Have you looked at The 30 Minute Regex Tutorial ? Good explanation there of the syntax with some examples...

  5. #5

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: [RESOLVED] regex question

    thanks for the tut gigem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width