I want to split the string that look like:
"NumberTest_0821_0304-1.0"
I want to split it as
['NumberTest', '0821_0304', '-1.'0] or ['NumberTest', '0821_0304', '1.0']
I tried
re.split(r'\W+|\\_|\\-', str)
But this gives
['NumberTest', '0821', '0304', '1', '0']
try this
import re
str='NumberTest_0821_0304-1.0'
print(re.findall('[A-Za-z]+|\d[\_]+|\d[\.\d.]+',str ))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.