Luckily, Python has this built-in 🙂
import re
re.split('; |, ',str)
Update:
Following your comment:
>>> a="Beautiful, is; better*than\nugly"
>>> import re
>>> re.split('; |, |\*|\n',a)
['Beautiful', 'is', 'better', 'than', 'ugly']
More Related Contents:
- How can I split by 1 or more occurrences of a delimiter in Python?
- Split Strings into words with multiple word boundary delimiters
- Split string every nth character?
- Split a string by a delimiter in python
- Split string on whitespace in Python [duplicate]
- How to split a string of space separated numbers into integers?
- Python split() without removing the delimiter [duplicate]
- Why are empty strings returned in split() results?
- Splitting a string into words and punctuation
- Reading a text file and splitting it into single words in python
- Product code looks like abcd2343, how to split by letters and numbers?
- Get last “column” after .str.split() operation on column in pandas DataFrame
- Splitting a semicolon-separated string to a dictionary, in Python
- Splitting on last delimiter in Python string?
- Python split string into multiple string [duplicate]
- When splitting an empty string in Python, why does split() return an empty list while split(‘\n’) returns [”]?
- Splitting a string by list of indices
- Split a string only by first space in python
- How to split strings inside a list by whitespace characters
- Convert string to list. Python [string.split() acting weird]
- How would I get everything before a : in a string Python
- Python regex: splitting on pattern match that is an empty string
- Convert list of strings to dictionary
- Is there a way to split a string by every nth separator in Python?
- How can I split a string of a mathematical expressions in python?
- How to split a Python string on new line characters [duplicate]
- Split string at nth occurrence of a given character
- Split text after the second occurrence of character
- Split a string into 2 in Python
- Splitting a math expression string into tokens in Python