I am trying to split a String into a list every time the word '::' or 'episode' appear. I want to split the list every time one of those words appears but I can only give one word to the method 'split()'.
I think this code will help
import re
delimiters = "::", "episode"
example = "hello:: this episode is my favourite"
regexPattern = '|'.join(map(re.escape, delimiters))
print(re.split(regexPattern, example))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.