,可以通过以下步骤实现:
import re
pattern1 = r'模式1'
pattern2 = r'模式2'
请将"模式1"和"模式2"替换为实际的正则表达式模式。
text = "待匹配的字符串"
请将"待匹配的字符串"替换为实际的待匹配字符串。
matches1 = re.findall(pattern1, text)
matches2 = re.findall(pattern2, text)
matches1和matches2分别保存了两个模式的匹配结果。
print("模式1的匹配结果:", matches1)
print("模式2的匹配结果:", matches2)
完整的代码示例:
import re
pattern1 = r'模式1'
pattern2 = r'模式2'
text = "待匹配的字符串"
matches1 = re.findall(pattern1, text)
matches2 = re.findall(pattern2, text)
print("模式1的匹配结果:", matches1)
print("模式2的匹配结果:", matches2)
请将"模式1"、"模式2"和"待匹配的字符串"替换为实际的值。
领取专属 10元无门槛券
手把手带您无忧上云