diff options
author | Guido van Rossum <guido@python.org> | 1997-10-22 21:00:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-22 21:00:49 (GMT) |
commit | 9694fcab5332f27dc28b195ba1391e5491d2eaef (patch) | |
tree | 23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/tzparse.py | |
parent | 426916e50e1209d8ecc12678855dc531863a48c5 (diff) | |
download | cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.bz2 |
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/tzparse.py')
-rw-r--r-- | Lib/tzparse.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/tzparse.py b/Lib/tzparse.py index ef325e9..358e0cc 100644 --- a/Lib/tzparse.py +++ b/Lib/tzparse.py @@ -2,23 +2,22 @@ # XXX Unfinished. # XXX Only the typical form "XXXhhYYY;ddd/hh,ddd/hh" is currently supported. -tzpat = '^\([A-Z][A-Z][A-Z]\)\([-+]?[0-9]+\)\([A-Z][A-Z][A-Z]\);' + \ - '\([0-9]+\)/\([0-9]+\),\([0-9]+\)/\([0-9]+\)$' +tzpat = ('^([A-Z][A-Z][A-Z])([-+]?[0-9]+)([A-Z][A-Z][A-Z]);' + '([0-9]+)/([0-9]+),([0-9]+)/([0-9]+)$') tzprog = None def tzparse(tzstr): global tzprog if tzprog == None: - import regex - tzprog = regex.compile(tzpat) - if tzprog.match(tzstr) < 0: + import re + tzprog = re.compile(tzpat) + match = tzprog.match(tzstr) + if not match: raise ValueError, 'not the TZ syntax I understand' - regs = tzprog.regs subs = [] for i in range(1, 8): - a, b = regs[i] - subs.append(tzstr[a:b]) + subs.append(match.group(i)) for i in (1, 3, 4, 5, 6): subs[i] = eval(subs[i]) [tzname, delta, dstname, daystart, hourstart, dayend, hourend] = subs |