Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有多个包含字母和数字部分的字符串,我想将这些部分分开。
a='swich 125mg' re.findall(r'[A-Za-z]+|\d+',a) output--> ['swich','125','mg']
我得到了所需的输出。但是当我有另一个字符串时
a="voglikem 0.2 tablets (10's)" a=['voglikem', '0', '2', 'tablets', '10', 's']
0.2分开0,2我不想要。有什么可以帮助我的吗?
0.2
0
2
只需添加.并\d包装它[]
.
\d
[]
[A-Za-z]+|[\d.]+