Help with regular expression in python

jmfauth wxjmfauth at gmail.com
Fri Aug 19 11:50:51 EDT 2011


On 19 août, 17:20, Matt Funk <matze... at gmail.com> wrote:
> Hi,
> thanks for the suggestion. I guess i had found another way around the
> problem as well. But i really wanted to match the line exactly and i
> wanted to know why it doesn't work. That is less for the purpose of
> getting the thing to work but more because it greatly annoys me off that
> i can't figure out why it doesn't work. I.e. why the expression is not
> matches {32} times. I just don't get it.
>

re is not always the right tool to be used.
Without more precisions:

>>> s = '2.201000e+01 2.150000e+01 2.150000e+01\
...  : (instance: 0)       :       some description'
>>> s
2.201000e+01 2.150000e+01 2.150000e+01 : (instance: 0)       :
some description
>>> s[:s.find(':')]
2.201000e+01 2.150000e+01 2.150000e+01
>>> s[:s.find(':')].split()
['2.201000e+01', '2.150000e+01', '2.150000e+01']
>>>
>>>

jmf



More information about the Python-list mailing list