To do this using
re.split
you can do:re.split(r'(>+|!+|]+)', string)
Explaining this briefly:
- You split on one or more occurrences of the different delimiters (
>
,!
,]
). - In order to include the delimiters in the result, you put the pattern in a capturing group by putting parens around it.
from : https://stackoverflow.com/questions/32856012/how-do-you-split-a-string-in-python-with-multiple-delimiters
No comments:
Post a Comment