On Jun 24, 3:56 am, Kurt Mueller <[EMAIL PROTECTED]> wrote:
> How to (super)split a string (literal) containing " and/or ' and/or \<sep>.
>
> example:
>
> ' a " b b " c\ c '.supersplit(' ')
> ->
> ['a', ' b b ', 'c c']
>
> Thanks and Grüessli
> --
> Kurt Müller:
> [EMAIL PROTECTED]
Or did you mean this?
>>> re.split(r'''['"]|\\ ''',' a " b b " c\ c ')
[' a ', ' b b ', ' c', 'c ']
(In your example, you should prefix you quoted string literal with an
r, as in:
r' a " b b " c\ c '.supersplit(' ')
That way, the '\' character will be treated as just any other
character.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list