Split a string on several delimiters at once: delete every character covered by an occurrence of any delimiter, overlapping occurrences included, and return the non-empty pieces.
Unlock detailed company stats for this questionUpgrade
Write split(text, delimiters), which splits a string on several delimiter strings at once and returns a flat list of the pieces in their original order. Empty pieces are dropped, so splitting a string that is exactly one of the delimiters returns an empty list. Occurrences of delimiters may overlap each other in the text, and when they do, every character covered by any of the overlapping occurrences is removed. Put another way: mark each character that lies inside at least one occurrence of some delimiter, delete the marked characters, and return the non-empty runs that remain. Examples: split('banana bread', ['an', 'b']) returns ['a ', 'read']; split('seashell', ['eas', 'ash']) returns ['s', 'ell'], because the two delimiters overlap on 'as' and together remove 'eash'.
Community answers
No answers contributed by the community yet.
Related questions
Given a list of strings, find the number of occurrences of the second letter of the first word, and return the character and its count.Related courses

Course
