diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 5ca562c07..1268d92af 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -39,9 +39,6 @@ import numpy as np import re import itertools -reFloat = re.compile(r'\+?\d*\.?\d+([eEdD][-+]?\d+)?$') -reInt = re.compile(r'\+?\d+$') - QUANTITY_UNITS = {'MOL': 'mol', 'MOLE': 'mol', 'MOLES': 'mol', @@ -1077,12 +1074,16 @@ class Parser(object): j = reaction.find(token) i = len(token) reaction = reaction[:j] + ' '*i + reaction[j+i:] - if reInt.match(token): + if token == '+': + continue + + try: locs[j] = int(token), 'coeff' - elif reFloat.match(token): - locs[j] = float(token), 'coeff' - elif token != '+': - raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction)) + except ValueError: + try: + locs[j] = float(token), 'coeff' + except ValueError: + raise InputParseError('Unexpected token "{0}" in reaction expression "{1}".'.format(token, reaction)) reactants = [] products = []