On Thu, Aug 7, 2008 at 5:25 PM, dave selby <[EMAIL PROTECTED]> wrote: > Hi all, > > Is there a neat way to split a string on either of two delimiters ie > space and comma
Use re.split(): In [1]: import re In [2]: data = 'tom,dick harry' In [4]: re.split(r'[, ]', data) Out[4]: ['tom', 'dick', 'harry'] Since you have the full power of re to match your delimiter you could for example allow comma, space or both: In [6]: re.split(r', *| +', 'tom, dick,harry and bill') Out[6]: ['tom', 'dick', 'harry', 'and', 'bill'] Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor