Fredrik Lundh wrote:
> bon
...@gmail.com wrote:
> > are there a strtok equivalent in python ? str.split() only takes single
> > seperator.
> use a regular expression split with a character group:
> >>> s = "breakfast=spam+egg-bacon"
> >>> import re
> >>> re.split("[-+=]", s)
> ['breakfast', 'spam', 'egg', 'bacon']
> to deal with an arbitrary set of delimiting characters without having to
> bother with RE syntax, use re.escape:
> >>> re.split("[" + re.escape("-+=") + "]", s)
> ['breakfast', 'spam', 'egg', 'bacon']
> </F>