Answers for "python split string on multiple delimiters"

10

how to split a string in python with multiple delimiters

>>> a='Beautiful, is; better*thannugly'
>>> import re
>>> re.split('; |, |*|n',a)
['Beautiful', 'is', 'better', 'than', 'ugly']
Posted by: Guest on June-09-2020
1

python split every character in string

def split(word): 
    return [char for char in word]
Posted by: Guest on September-21-2020
-1

python split multiple delimiters

#Do a str.replace('? ', ', ') and then a str.split(', ')
#Example:
a = "Hello, what is your name? I'm Bob."
a.replace('? ', ', ')
print(a)
#"Hello, what is your name, I'm Bob."
a.split(", ")
print(a)
#["Hello", "what is your name", "I'm Bob."]
Posted by: Guest on March-15-2021

Code answers related to "python split string on multiple delimiters"

Python Answers by Framework

Browse Popular Code Answers by Language