split encloser

Chris aussie2010 at yahoo.com
Thu Apr 3 18:30:10 EST 2003


string.split() takes a delimiter and works fine as long as the
delimiter isn't part of the data fields. But frequently they are.
e.g. 'John Doe,135 South Main St.,#122, Springfield, Iowa' or
      ' so long goodbye see ya'

Because the fields can contain the delimiter in some cases, an
encloser is usually used (typically "") to handle those fields.

The above strings would be written:
'John Doe,"135 South Main St., #122", Springfield, Iowa'
and 
'"so long" goodbye "see ya"'

I don't understand regular expressions but I was wondering if anyone
that did knew of a way to get re.split() to handle "enclosers" as used
above.




More information about the Python-list mailing list