On Feb 3, 11:40 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, vishal wrote: > > I am trying to work out a regular expression in a PyQt environment for > > time in hh:mm:ss format. Any suggestions? > > Maybe don't use a re for something that simple. Splitting at ``:`` > characters, converting to `int` and checking the value ranges isn't that > hard without a regular expression. > > Ciao, > Marc 'BlackJack' Rintsch
Except that if a full regex is used, the pattern can be matched or denied and pull out the important information simultaneously. Here's a simple regex that would work: (\d{1,2}):(\d{1,2}):(\d{1,2}) but here's one that works only for the 12 hour clock: ((1[012])|(0?\d)):([0-5]?\d):([0-5]?\d) and one for the 24 hour clock: ((2[0-4])|([01]?\d)):([0-5]?\d):([0-5]?\d) I hope this helps --Tim -- http://mail.python.org/mailman/listinfo/python-list