split string but ignore sep inside double quotes

Andrea Crotti andrea.crotti.0 at gmail.com
Wed Apr 13 12:24:35 EDT 2011

Andrea Crotti <andrea.crotti.0 at gmail.com> writes:
> I'm not sure how but also this seems to work:
> In[20]: s = '2,"some, text",more text'
> In [21]: re.split(r'(?<=">),', s)
> Out[21]: ['2,"some, text",more text']
> I just wanted to try the lookahead functions, which I never use but
> sometimes might come handy.

Eh eh no sorry I misread the output, it's a list with one element in
this case...
So anyway I suppose you can look ahead or before if there is a " and
don't match the "," in this case, that was the main idea.

More information about the Python-list mailing list