Mark Harrison wrote:
> What is the best way to process a text file of delimited strings?
> I've got a file where strings are quoted with at-signs, @like [EMAIL 
> PROTECTED]
> At-signs in the string are represented as doubled @@.

>>> import re
>>> _at_re = re.compile('(?<!@)@(?!@)')
>>> def split_at_line(line):
...     return [field.replace('@@', '@') for field in
...                               _at_re.split(line)]
...
>>> split_at_line('[EMAIL PROTECTED]@@[EMAIL PROTECTED]')
['foo', '[EMAIL PROTECTED]', 'qux']
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to