re.split
re.split() splits a string at each regex match. Useful for splitting on variable whitespace or multiple delimiters.
re.split() splits a string at each regex match. Useful for splitting on variable whitespace or multiple delimiters.
import re
text = "one, two; three|four"
parts = re.split(r"[,;|\s]+", text)
print(parts)
# ["one", "two", "three", "four"]
Capture groups in the pattern are included in the split result.