regex - How to match only letters from a string containing alphanumeric and symbols?
问题描述
log : Description: "AMEND - 04 ACCEPTED" Output: AMEND ACCEPTED
I have tried to write regex as Description:\s"([A-Z]+)". but its matching only 1st word.
解决方案
根据您的工具或语言,正则表达式 find all 可能在这里最有意义。你可以在模式上匹配\b[A-Z]+\b
。
在 Python 中,我们可以尝试:
inp = "AMEND - 04 ACCEPTED"
matches = re.findall(r'\b[A-Z]+\b')
print(matches) # ['AMEND', 'ACCEPTED']
推荐阅读
- android - /apex/com.android.runtime/lib64/bionic/libc.so (abort+160),在 Android 10 设备中中止崩溃
- python - 在python中查找内部括号字符串和外部括号字符串
- python - 给定路径中没有 chrome 二进制文件 - MacOS - Selenium - Python
- javascript - 如何使用 Wordpress 设计自定义服务网站?
- c# - 在c#代码中获取http web请求发送错误
- javascript - 按钮显示在本地文件上,但在 heroku 中的 web 上部署时不显示
- sql - 如何在 Doctrine 中按日期时间排序,但首先显示没有日期的数据
- javascript - 经典 ASP + AJAX 变量引用
- python - 将一行中的单元格数据拆分到不同的行,并将同一行中的其他数据复制到所有新添加的行中
- node.js - 如何在 pm2 中通过 https 提供静态文件?