# 要求匹配abc,abc后面只要不跟连续的df就能匹配到 import re reg = re.compile(".*(abc(?!(df))|xxxx).*") print(re.match(reg, "ssadxxxx")) print(re.match(reg, "ssabcxx")) print(re.match(reg, "ssabcdfxx"))
正则匹配不包含与包含
原文:https://www.cnblogs.com/lajiao/p/10626448.html