How to split a string by hyphen using regex in Python

1 Answer

0 votes
import re
 
s = 'Python-Java-PHP-C#-C++'
 
sp = re.split('-', s)
 
print(sp)
 
  
'''
run:
  
['Python', 'Java', 'PHP', 'C#', 'C++']
  
'''

 



answered Jul 31, 2019 by avibootz

Related questions

...