我有这个模式
Calibration attempts: 0
Successful calibrations: 0
Calibration attempts: 0
Successful calibrations: 0
我需要一个正则表达式来完全匹配它。这根本不应该匹配:
Calibration attempts: 1
Successful calibrations: 0
Calibration attempts: 0
Successful calibrations: 0
到目前为止我只想到了这个,但看起来很糟糕。
(.*Calibration attempts: 0\n.*Successful calibrations: 0\n.*Calibration attempts: 0\n.*Successful calibrations: 0.*)
最佳答案
这应该有效:(^[\t ]+(Calibration|Successful| |attempts|calibrations)+: 0$\n?){4}
查看regex101.com,您可以在那里进行测试。 我测试了这种情况,不匹配任何非“0”的内容
干杯。
关于python - 准确匹配句子 4 次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61772012/