I am trying to capture / extract numerical values from some strings.
Here is an example line:
s='The shipping company had 93,999,888.5685 gallons of fuel on hand'
I want to pull out the value 93,999,888.5685 I got my regex for this
> mine=re.compile("(\d{1,3}([,\d{3}])*[.\d+]*)")
However, when I do findall, I get the following:
mine.findall(s)
[('93,999,888.5685', '8')]
I tried several different strategies so as not to compare it with 8
But now I understand that I'm not sure I know why it matched 8
Any coverage would be appreciated.
source
share