aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/fpformat.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-22 21:00:49 +0000
committerGuido van Rossum <guido@python.org>1997-10-22 21:00:49 +0000
commit9694fcab5332f27dc28b195ba1391e5491d2eaef (patch)
tree23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/fpformat.py
parent426916e50e1209d8ecc12678855dc531863a48c5 (diff)
downloadcpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/fpformat.py')
-rw-r--r--Lib/fpformat.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/fpformat.py b/Lib/fpformat.py
index 457457595c8..404738d79bf 100644
--- a/Lib/fpformat.py
+++ b/Lib/fpformat.py
@@ -11,11 +11,11 @@
# digits_behind: number of digits behind the decimal point
-import regex
+import re
# Compiled regular expression to "decode" a number
-decoder = regex.compile( \
- '^\([-+]?\)0*\([0-9]*\)\(\(\.[0-9]*\)?\)\(\([eE][-+]?[0-9]+\)?\)$')
+decoder = re.compile( \
+ '^([-+]?)0*([0-9]*)((\.[0-9]*)?)(([eE][-+]?[0-9]+)?)$')
# \0 the whole thing
# \1 leading sign or empty
# \2 digits left of decimal point
@@ -30,10 +30,9 @@ NotANumber = 'fpformat.NotANumber'
# fraction is 0 or more digits
# expo is an integer
def extract(s):
- if decoder.match(s) < 0: raise NotANumber
- (a1, b1), (a2, b2), (a3, b3), (a4, b4), (a5, b5) = decoder.regs[1:6]
- sign, intpart, fraction, exppart = \
- s[a1:b1], s[a2:b2], s[a3:b3], s[a5:b5]
+ m = decoder.match(s)
+ if not m: raise NotANumber
+ sign, intpart, fraction, exppart = m.group(1, 2, 3, 5)
if sign == '+': sign = ''
if fraction: fraction = fraction[1:]
if exppart: expo = eval(exppart[1:])