Leif K-Brooks wrote:
> 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']
The plot according to the OP was that the @s were quotes, NOT delimiters.
--
http://mail.python.org/mailman/listinfo/python-list