How to split string by multiple underscores in Python

1 Answer

0 votes
import re

s = 'python__java_____php   _c_________c++'

chunks = re.split('_+', s)

print(chunks)



'''
run:

['python', 'java', 'php   ', 'c', 'c++']

'''

 



answered Jan 10, 2021 by avibootz
...