Thanks for all the postings. I can't change delimiter in the source
itself, so I'm doing it temporarily just to handle the escaping:

def splitWithEscapedCommasInParens(s, trim=False):
        pat = re.compile(r"(.+?\([^\(\),]*?),(.+?\).*)")
        while pat.search(s):
                s = re.sub(pat,r"\1|\2",s)
        if trim:
                return [string.strip(string.replace(x,"|",",")) for x in
string.split(s,",")]
        else:
                return [string.replace(x,"|",",") for x in string.split(s,",")]

Probably not the most efficient, but its "the simplest thing that
works" for me :-)

Thanks again for all the quick responses.

Ramon

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

Reply via email to