A regular expression can describe a family of separators in one pass. Consecutive separators raise a separate question about empty fields.
Worked example
import re
print(re.split(r'[,;]+', 'red,green;blue'))Result
['red', 'green', 'blue']Implementation notes
A capturing group changes what re.split returns. Use a noncapturing group when only the fields, rather than the matched delimiters, belong in the result.
Try it yourself
Feed the parser a trailing delimiter and two different adjacent delimiters.
Open the Python example →Editorial date July 6, 2025 · Published December 6, 2026