multiple pattern regular expression
Nick Stinemates
nick at stinemates.org
Sat Apr 26 01:04:54 EDT 2008
On Fri, Apr 25, 2008 at 08:40:55PM -0400, Carsten Haese wrote:
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
Didn't see that
--
Nick Stinemates (nick at stinemates.org)
http://nick.stinemates.org
More information about the Python-list
mailing list