I am creating a regex to parse a string of time zones. The output must be reading input in the following form:
0930
0930+10930-1
<0930
(>0930) (the brackets are just to avoid stack reading this as '<>')
(<0920+1)
(>0920+1)
0920-1240 +1
1200-1-1430
1200-1-1400+1
0920-1240 <<<<<<<<<<<<<<<<<<<<<<<<<ISSUE HERE
The regex cannot differentiate between hhmm-1, and hhmm-hhmm. It will read '0900-1200' as '0900-1'.
I have attempted many variateions of the regex, including:
r'([<>])?([0-9]{2})([0-9]{2})([+-]?)([0-1]?)|([0-9]{2})([0-9]{2})'
r'([<>])?([0-9]{2})([0-9]{2})([+-])?([0-1]?)(([0-1]?{4})()'
r'([<>])?([0-9]{2})([0-9]{2})([+-])?([0-1]?)(?([0-1]?)()'
Currently just considering using 2 different ones! One to test for case of hyphenated time string, the other for the rest,which work for me. I would like the output in a list of tuples, like
[('', '09', '30', '-', '','12','30', '-', '1'),
('', '09', '30', '-', '1','','', '', ''),
('>', '09', '30', '-', '1','','', '', '').....]