Finally RegEx Time!!

Leave a Reply

Comment as a guest.

  1. Hello!
    This is Ashok Srivastav working as a software engineer.I would like to ask you aregular expression for Time(24 hrs) that means 11:00:00 or 23:00:00

  2. Ashok, I don’t quite get your question? Are you asking for a RegEx to validate time format or something or what?
    You can try this RegEx, though I don’t consider myself to be anything but a n00b in RegEx myself!! πŸ˜‰

    ^([0-23]{1,2}):([0-59]{1,2}):([0-59]{1,2})$

  3. <!– Author Edit –>

    @Amit: I think a String like 23:23:5959:5959 would be recognized as ‘true’ with your regexpression.

  4. Ali, no point in bashing up other people unnecessarily. If you want to do that, do it elsewhere, not my websites.

    @Amit: I think a String like 23:23:5959:5959 would be recognized as ‘true’ with your regexpression.

    Nah, you are wrong here, it wouldn’t be validated as ‘true’ because the RegEx will accept only 2 colons which I put in the expression. Though I won’t deny that the RegEx I gave is not wrong, I mean its not fully correct, there are some instances where its not working, as I just checked it, but then I never said that I’m great shakes in it, its still greek to me!! πŸ˜‰

Sliding Sidebar