python - Python Re:如何匹配任何至少有 1 个字母的字符串?
问题描述
我只想匹配任何至少有 1 个字母的字符串。请参见下面的示例。谢谢
import re
string1= "23 2021Sep Oct2021 Pte. 9K8 Ltd,"
Desired Outcome --> ['2021Sep' ,'Oct2021', 'Pte', '9K8', 'Ltd']
解决方案
你可以像这样没有 re :
[''.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']
推荐阅读
- android - 如何防止 Line Reader 跳过第一行?
- javascript - Vanilla JS Jest 测试点击事件
- python - 如何更改 Python sys.path 以防止在 pip 安装指向错误目录的 Python 包时发生 Permission Denied?
- c# - 依赖于被调用接口的其他成员的单元测试方法
- r - 计算变量内区间的平均值
- python - 设置标志后线程不会停止
- html - CSS height 属性调整 iframe 大小错误
- python - python pandas数据框将列重命名为多索引列
- c# - 可选地使用必填字段和 ASP.NET MVC 数据注释
- php - dyld:库未加载:/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib、php-fpm、php5.6