Python Forum

Full Version: function t split a string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i just wrote a function to split a string into parts based on a list of delimiters used in sequence.

>>> splits('abcdefghijklm',['b','ef','ij'])
['a','cd','gh','klm']
i wrote this because i needed it in a big script i was making. did i waste my time doing this?
re.split
what i wrote uses a list of (usually different) delimiters, each doing a split only once. and the delimiters are raw, so the code that creates them does not need to translate them to regular expressions.