Help with regular expression in python

Jason Friedman jason at powerpull.net
Fri Aug 19 10:41:49 EDT 2011


> Hi Josh,
> thanks for the reply. I am no expert so please bear with me:
> I thought that the {32} was supposed to match the previous expression 32
> times?
>
> So how can i have all matches accessible to me?

$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> data
'1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01
1.914000e+01 2.007000e+01 1.664000e+01 2.204000e+01 2.109000e+01
2.209000e+01 2.376000e+01 2.158000e+01 2.177000e+01 2.152000e+01
2.267000e+01 1.084000e+01 1.671000e+01 1.888000e+01 1.854000e+01
2.064000e+01 2.000000e+01 2.200000e+01 2.139000e+01 2.137000e+01
2.178000e+01 2.179000e+01 2.123000e+01 2.201000e+01 2.150000e+01
2.150000e+01 2.199000e+01 : (instance: 0)       :       some
description'
>>> import re
>>> re.findall(r"\d\.\d+e\+\d+", data)
['1.002000e+01', '2.037000e+01', '2.128000e+01', '1.908000e+01',
'1.871000e+01', '1.914000e+01', '2.007000e+01', '1.664000e+01',
'2.204000e+01', '2.109000e+01', '2.209000e+01', '2.376000e+01',
'2.158000e+01', '2.177000e+01', '2.152000e+01', '2.267000e+01',
'1.084000e+01', '1.671000e+01', '1.888000e+01', '1.854000e+01',
'2.064000e+01', '2.000000e+01', '2.200000e+01', '2.139000e+01',
'2.137000e+01', '2.178000e+01', '2.179000e+01', '2.123000e+01',
'2.201000e+01', '2.150000e+01', '2.150000e+01', '2.199000e+01']



More information about the Python-list mailing list