HELP NEEDED ... Regd. Regular expressions PyQt

V

vishal

Hello All:
I am trying to work out a regular expression in a PyQt environment for
time in hh:mm:ss format. Any suggestions?
Thanks,
Vishal
 
M

Marc 'BlackJack' Rintsch

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
 
T

timothy.kellogg

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
 
N

Neil Cerutti

I am trying to work out a regular expression in a PyQt
environment for time in hh:mm:ss format. Any suggestions?

After you find your time in hh:mm:ss format, be sure to check out
time.strptime for a quick conversion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top