Monday
May022011
Python super_split()
Monday, May 2, 2011 at 04:55PM I recently needed some code that splits python strings based on multiple delimitors, so I wrote a quick function to do so. I figured it’s generally useful so I’m posting it here.
def super_split(string, delim):
segment = ''
for c in string:
if c in delim:
yield segment
segment = ''
else:
segment += c
yield segment