python-3.x - 正则表达式匹配不正常,每次都给出空白列表
问题描述
我想从 txt 匹配 From Jun-2020 To Jun-2020,但我每次都得到空字符串。
import re
txt = "Monthly Data Item Wise Report Across Facility From Jun-2020 To Jun-2020 Data as on 24th February 2021 11:20:24 AM"
x = re.findall("^ From *[abceglnoprtuvyADFJMNOS|]{3}[\s-]\d{2,4} To *[abceglnoprtuvyADFJMNOS|]{3}[\s-]\d{2,4}", txt)
print(x)
解决方案
推荐阅读
- aem - 以编程方式激活 aem 中的页面
- sql - 如何在 SQL 中对行进行分组并总结?
- ios - 即使在 SDK 升级后,Facebook iOS 14.0+ 应用程序安装仍停留在“验证您的更改”
- ocaml - OCaml 中的比较不再是多态的吗?
- vue.js - Vue 的仅运行时构建到底是什么,它与编译器构建有何不同?
- c# - Razor Pages .Net Core - 从 Javascript / AJax 调用 C# 方法
- html - 如何防止网格与页面标题重叠并在调整视口大小时避免滚动条?
- c - 错误:非 void 函数不会在所有控制路径中返回值
- python - 在 Python 中获取 Unix 时间
- usb - 使用 Pi Zero W 模拟 HID 键盘和鼠标