I have a string that I need to split on multiple characters without the use of regular expressions. for example, I would need something like the following:
>>>string="hello there[my]friend"
>>>string.split(' []')
['hello','there','my','friend']
is there anything in python like this?
If you need multiple delimiters,
re.splitis the way to go.Without using a regex, it’s not possible unless you write a custom function for it.
Here’s such a function – it might or might not do what you want (consecutive delimiters cause empty elements):