multiple pattern regular expression
Carsten Haese
carsten.haese at gmail.com
Fri Apr 25 20:40:55 EDT 2008
Nick Stinemates wrote:
> On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote:
>> How about this?
>>
>> for line in file:
>> # ignore lines without = assignment
>> if '=' in line:
>> property, value = line.strip().split( '=', 1 )
>> property = property.strip().lower()
>> value = value.strip()
>>
>> # do something with property, value
>>
>> Malcolm
>
> This works until you have:
> string=The sum of 2+2=4
Actually, it still works, because Malcolm used split()'s maxsplit parameter.
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list