Recently in a Python webinar, a question was raised by someone on how to split strings with multiple delimiters in Python. After exploring various methods I found five effective ways to accomplish this task. Let us learn all the methods with suitable examples.
Split Strings with Multiple Delimiters in Python
In Python, you can split strings with multiple delimiters using different methods, Let us see all the important methods.
Read How to Convert Hexadecimal String to Integer in Python?
Method 1. Use re.split() Function
The re.split() function in Python allows you to split a string using multiple delimiters in one go.
Example: Split a USA address with multiple delimiters (,, ;, and |).
import re
address = "New York, NY; Los Angeles | San Francisco, CA"
cities = re.split(r"[,;|]\s*", address) # Splitting by `,`, `;`, or `|` followed by optional spaces
print(cities)Output:
['New York', 'NY', 'Los Angeles', 'San Francisco', 'CA']I have executed the above example code and added the screenshot below.

The regex pattern [ ,;|]\s* matches commas, semicolons, or pipes followed by spaces.
Check out How to Pad Strings with Spaces in Python?
Method 2. Use re.findall() Method
The re.findall() method in Python extracts words while ignoring delimiters.
Example: Extract USA phone numbers split by multiple delimiters.
import re
phone_numbers = "123-456-7890, 987.654.3210 | (555) 123 4567"
numbers = re.findall(r"\d{3}[-.\s]?\d{3}[-.\s]?\d{4}", phone_numbers)
print(numbers)Output:
['123-456-7890', '987.654.3210']I have executed the above example code and added the screenshot below.

The regex pattern \d{3}[-.\s]?\d{3}[-.\s]?\d{4} captures USA phone numbers with different separators (-, ., space).
Read How to remove specific words from a string in Python?
Method 3. Use translate() & maketrans() Methods
The translate() in Python method removes unwanted characters efficiently.
Example: Split a USA address with multiple delimiters (,, ;, and |).
state_list = "California, Texas; Florida | New York"
trans_table = str.maketrans(",;|", " ") # Replace `,`, `;`, `|` with spaces
cleaned_states = state_list.translate(trans_table).split()
print(cleaned_states)Output:
['California', 'Texas', 'Florida', 'New York']I have executed the above example code and added the screenshot below.

maketrans(",;|", " ") replaces ,, ;, and | with spaces. .translate(trans_table) applies the mapping. .split() then removes extra spaces.
Check out Find the First Number in a String in Python
Method 4. Use replace() Method
You can use .replace() in Python to replace delimiters with spaces before splitting.
Example: Clean up ZIP codes separated by different delimiters.
zip_codes = "10001,90210; 33101 | 77001"
for delimiter in [",", ";", "|"]:
zip_codes = zip_codes.replace(delimiter, " ") # Replace each delimiter with a space
zip_list = zip_codes.split() # Split using whitespace
print(zip_list)Output:
['10001', '90210', '33101', '77001'].replace(",", " "), .replace(";", " "), etc., replaces different delimiters with spaces..split() then separates words using whitespace.
Read How to Compare Strings in Python?
Method 5. Use split() Function
The split() function in Python can handle a single delimiter but can be used repeatedly.
Example: Split a list of USA cities with a single delimiter.
cities = "Chicago|Houston|Seattle|Miami"
city_list = cities.split("|") # Using `|` as the delimiter
print(city_list)Output:
['Chicago', 'Houston', 'Seattle', 'Miami']split("|") breaks the string at every |.
Check out How to Create a String of N Characters in Python?
Conclusion
In this tutorial, I have explained how to split strings with multiple delimiters in Python. I covered mainly five methods to achieve this task such as using the re.split() function, re.findall() method, translate() and maketrans() methods, replace() method, and split() function.
You may also read:
- How to Split a String into Equal Parts in Python?
- How to Insert a Python Variable into a String?
- How to Split a String by Index in Python?

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.