Python Forum
function t split a string - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: function t split a string (/thread-17757.html)



function t split a string - Skaperen - Apr-23-2019

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: function t split a string - Larz60+ - Apr-23-2019

re.split


RE: function t split a string - Skaperen - Apr-23-2019

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.