我需要找到2个正则表达式模式,但我没有找到让它工作
我有一个变量可以是其中的一个(只是例子更多)
repository = "Red Hat Enterprise Linux Extended Update Support 7.2"
repository = "Red Hat Enterprise Linux 7"
我需要找到两个具有这种模式的存储库:
regex_rhel = 'Red Hat Enterprise Linux' + " " + str(major_version)
regex_eus = 'Red Hat Enterprise Linux Extended Update Support' + " " + str(rhel_ver)
我试过芬德尔,但得到:
eus_latest_repos = re.findall(r'"Red Hat Enterprise Linux' + " " + str(major_version)|('Red Hat Enterprise Linux Extended Update Support' + " " + str(rhel_ver),repository))
print(eus_latest_repos)
TypeError: unsupported operand type(s) for |: 'str' and 'tuple'
如果我知道你需要正则表达式从字符串中提取回购。你知道吗
演示:
输出:
相关问题 更多 >
编程相关推荐