I'm trying to match numbers in scientific notation (regex from here):
scinot = re.compile('[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)')
re.findall(scinot, 'x = 1e4')
['1e4']
re.findall(scinot, 'x = c1e4')
['1e4']
I'd like it to match x = 1e4
but not x = c1e4
. What should I change?
Update: The answer here has the same problem: it incorrectly matches 'x = c1e4'
.