Pyparsing includes some built-in quoted string support that might
simplify this problem.  Of course, if you prefer regexp's, I'm by no
means offended!

Check out my Python console session below.  (You may need to expand the
unquote method to do more handling of backslash escapes.)

-- Paul
(Download pyparsing at http://pyparsing.sourceforge.net.)

>>> from pyparsing import delimitedList, sglQuotedString
>>> text = r"'the','dog\'s','bite'"
>>> def unquote(s,l,t):
...     t2 = t[0][1:-1]
...     return t2.replace("\\'","'")
...
>>> sglQuotedString.setParseAction(unquote)
>>> g = delimitedList( sglQuotedString )
>>> g.parseString(text).asList()
['the', "dog's", 'bite']

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to