2024-10-01 05:01:47 发布
网友
我只想匹配任何至少有1个字母的字符串。见下面的例子。谢谢
import re string1= "23 2021Sep Oct2021 Pte. 9K8 Ltd," Desired Outcome --> ['2021Sep' ,'Oct2021', 'Pte', '9K8', 'Ltd']
你可以不这样做:
[''.join(cc for cc in w if cc.isalnum()) for w in string1.split() if any(c.isalpha() for c in w)]
输出
['2021Sep', 'Oct2021', 'Pte', '9K8', 'Ltd']
你可以不这样做:
输出
相关问题 更多 >
编程相关推荐