python - 多正则表达式在python中获取数字
问题描述
我不是正则表达式的专家,但我是从头开始做的,我需要根据这个抓取数字和字母 [ae]:
SnnEnn where n represent numbers
SnnEnnl where l = letter [a-e]
nnXnn where n represent numbers
nnXnnl where l = letter [a-e]
但在少数情况下它会失败:
02x01 match '02x01' fail (It should be '02' '01')
03x02a match '03x02'..............groups 'a' fail (It should be '03' '02' 'a')
S03E01 match 'S03E01'.............groups '03' '01' ok
S03E01a match 'S03E01a'............groups 'S03E01' 'a' fail.(It should be '03' '01' 'a')
03x02xxxx match '03X02xxxx' groups '03x02xxxx' fail (it should be just [a-e] and limit to one letter)
S03E01xxx match '03E01xxxx' groups '03e01xxxx' fail (idem)
我正在使用这个正则表达式:
(\d+[x]\d+\w)([a-e])|(\d+[x]\w+)|\bS(?P<Season>\d+)E(?P<Episode>\d+)|(\b[s]\d+[e]\d+)([a-e])
感谢您的帮助
解决方案
推荐阅读
- facebook - PSID 不支持 GET 请求 Graph API?
- xpath - c# html agility pack 从 html 源代码中提取字符串
- reactjs - REACT 导入 css 和 js 文件
- c# - .NET 中是否存在等效的 Trie 数据结构?
- ios - 如何在swiftui中处理RotationGesture的角度
- pyspark - 如何从文本中查找数字
- macos - 无法启动 DAML 工作室
- python-3.x - 以下代码的 Python GUI TKINTER SQLITE3 错误
- css - 无法使用 text-align 使文本居中:在角度材料应用程序中居中
- ios - 复杂视图中的 SwiftUI 字体缩放