我需要匹配大于 5 的失败计数。
string="""fail_count 7
fail_count 8
fail_count 9
fail count 7
fail_count 71
fail_count 23
"""
match = re.search(r'fail(\s|\_)count\s[5-9]', string)
if match:
print match.group()
Run Code Online (Sandbox Code Playgroud)
我最多可以匹配 9,但是如果我将范围增加到 999,它就不起作用。