Luckily, Python has this built-in :)

import re

# Regex pattern splits on substrings "; " and ", "
re.split('; |, ', string_to_split)

Update:

Following your comment:

>>> string_to_split = 'Beautiful, is; better*than\nugly'
>>> import re
>>> re.split('; |, |\*|\n', string_to_split)
['Beautiful', 'is', 'better', 'than', 'ugly']
Answer from Jonathan Livni on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-split-multiple-characters-from-string
Split a string on multiple delimiters in Python - GeeksforGeeks
July 12, 2025 - The re.split() function from the re module is the most straightforward way to split a string on multiple delimiters. It uses a regular expression to define the delimiters.
🌐
Medium
medium.com › @thecodeteacher › python-how-to-split-string-based-on-multiple-delimiters-f43984a8aa2b
Python — How To Split String Based on Multiple Delimiters | by thecodeteacher | Medium
January 26, 2022 - import re text = "python is# an% easy;language- to, learn." print(re.split('; |, |# |% |- ', text)) ... In this situation as well, we can simply use the same code we used earlier with two delimiters with a simple change of adding all additional separators into the separators variable.
🌐
Python.org
discuss.python.org › python help
Splitting a string on multiple delimiters - Python Help - Discussions on Python.org
April 5, 2023 - My issue is the same as in this topic: However, the suggested solutions won’t work for me. Here is my code: import re import string def func(line: str): # TODO: one-shot split fails delimiters = string.punctuation[:10] line_words = re.split(delimiters, line) # but splitting in steps does split_line = line.split(" ") for delimiter in string.punctuation: for unsplit_word in split_line: unsplit_word.split(delimiter) return split_line print(func(...
🌐
Reddit
reddit.com › r/c_programming › best way to split a string with multiple delimiters
r/C_Programming on Reddit: Best way to split a string with multiple delimiters
July 14, 2024 -

Hello. I'm working with user input and I'm looking for the most optimal way to split it with multiple delimiters. I will have for example this buffer: Hello, I am | a && human where | and && are delimiters. Not only do I need to split a string with these delimiters, I also need to store information about the delimiters: the order in which they appear in the initial buffer and also their corresponding delimiter type (so | or &&).

I attempted to use strtok() and while it does work for splitting the buffer using multiple delimiters I couldn't find a way to check which delimiter was used for tokenization.

Right now I'm thinking of just going through the buffer one char at a time and checking for delimiters that way which would allow me to see which delimiter it is and store the order in which they appear, but I'm unsure if this is the most efficient way of going through this.

Thanks

🌐
Stack Abuse
stackabuse.com › how-to-split-string-on-multiple-delimiters-in-python
How to Split String on Multiple Delimiters in Python
May 30, 2023 - For example, if we have a string with words separated by commas, semicolons, and/or spaces, str.split() cannot handle all these delimiters simultaneously. Advice: Reading our guide "Python: Split String into List with split()" will help you gain a deeper understanding of the split() method in Python. In the upcoming sections, we will explore more sophisticated techniques for splitting strings based on multiple delimiters in Python.
Find elsewhere
🌐
Medium
medium.com › @ryan_forrester_ › splitting-strings-with-multiple-delimiters-in-python-a-complete-guide-2e0c7b424811
Splitting Strings with Multiple Delimiters in Python: A Complete Guide | by ryan | Medium
October 28, 2024 - import re def parse_mixed_csv(text): """ Parse text that's structured like a CSV but with subcategories: - Rows are separated by newlines - Main fields are separated by commas - Some fields contain sublists separated by semicolons Example input: name,skills;level,location John Doe,Python;expert;SQL;intermediate,New York """ records = [] # Split into lines first (handling one row at a time) for line in text.strip().split('\n'): # Split fields by comma, but be smart about semicolons # The regex pattern looks for commas that have an even number of semicolons ahead fields = re.split(r',(?=[^;]*(?:
🌐
Note.nkmk.me
note.nkmk.me › home › python
Split a String in Python (Delimiter, Line Breaks, Regex) | note.nkmk.me
May 4, 2025 - This article explains how to split strings in Python using delimiters, line breaks, regular expressions, or a number of characters. Split a string by delimiter: split()Specify the delimiter: sepLimit ...
🌐
Mimo
mimo.org › glossary › python › string-split-method
Learn Python's String Split Method, Simplify Text Processing
To split a string using multiple delimiters, use the re module with regular expressions.
🌐
Daily.dev
app.daily.dev › home › stack abuse › how to split string on multiple delimiters in python
How to Split String on Multiple Delimiters in Python | daily.dev
June 2, 2023 - The str.split() method is Python's built-in approach to dividing a string into a list of substrings. This is where Python's ability to split strings on multiple delimiters truly shines.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › split the python string based on multiple delimiters
Split the Python String Based on Multiple Delimiters - Spark By {Examples}
May 21, 2024 - How to split a string based on multiple delimiters in Python? You can use the re.split() function of re module allows you to split a string based on
🌐
Sconts
sconts.com › post › split-string-with-multiple-delimiters-in-python
Split string with multiple delimiters in Python - 六二三's Blog
May 18, 2021 - Therefore when specifying the pattern of our regular expression, we can simply provide a semicolon and comma within square brackets and an additional space [;,] which would result in the regular expression being matched by parts of a string with exactly [a semicolon OR comma] and a trailing space. 1import re 2 3text = "python is, an easy;language; to, learn." 4print(re.split("[;,] ", text)) Prior mentioned basic expression was limited to a hardcoded set of separators. This can later on lead to hassles when delimiter modifications occur and also limits its reusability on other parts of the code.
🌐
HowToDoInJava
howtodoinjava.com › home › python string functions › python string split()
Python String split()
October 2, 2022 - >>> str = 'how to do in java' >>> str.split() # split string using default delimiter and max splits ['how', 'to', 'do', 'in', 'java'] #Output
🌐
PYnative
pynative.com › home › python › regex › python regex split string using re.split()
Python Regex Split String using re.split() – PYnative
July 27, 2021 - import re target_string = "12-45-78" # Split only on the first occurrence # maxsplit is 1 result = re.split(r"\D", target_string, maxsplit=1) print(result) # Output ['12', '45-78'] # Split on the three occurrence # maxsplit is 3 result = re.split(r"\D", target_string, maxsplit=3) print(result) # Output ['12', '45', '78']Code language: Python (python) Run · In this section, we’ll learn how to use regex to split a string on multiple delimiters in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-ways-to-split-strings-using-newline-delimiter
Ways to split strings using newline delimiter - Python - GeeksforGeeks
July 12, 2025 - It breaks the string into ["python", "java", "php"], separating the text at each \n. This method uses Python’s re (regular expression) module to define custom splitting patterns. It is best suited for splitting based on multiple types of line endings simultaneously, such as \n, \r or \r\n.
🌐
CyberChef
gchq.github.io › CyberChef
CyberChef
The 'Fork' operation (found in ... then displayed on a separate line. These delimiters can be changed, so if your inputs are separated by commas, you can change the split delimiter to a comma instead....