
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How we can break a string with multiple delimiters in Python?
We can break a string with multiple delimiters using the re.split(delimiter, str) method. It takes a regex of delimiters and the string we need to split. For example:
a='Beautiful, is; better*than\nugly' import re print(re.split('; |, |\*|\n',a))
We get the output
['Beautiful', 'is', 'better', 'than', 'ugly']
- Related Articles
- How can I use Python regex to split a string by multiple delimiters?
- How to split strings on multiple delimiters with Python?
- How to Split a String with Escaped Delimiters?
- How do we split a string with any whitespace chars as delimiters using java?
- How can we do Python operator overloading with multiple operands?
- Can we use break statement in a Python if clause?
- How we can bundle multiple python modules?
- Python Program to Join strings by multiple delimiters
- How we can extend multiple Python classes in inheritance?
- How can we print multiple blank lines in python?
- In MySQL, how can we pad a string with another string?
- How can we get substring from a string in Python?
- How can we check if specific string occurs multiple times in another string in Java?
- Check If a String Can Break Another String in C++
- How we can split Python class into multiple files?

Advertisements