python - Why does IN not evaluate my regular expression? -


using python 3.x, parsing through log files, , on lines there 1 of 3 key words (info, error, or warn).

i defining regular expression see if line contains either of these words as:

info|error|warn 

i correct way go this, not seem working. know missing here?

i checking see if regular expression in line printing it:

properties.py     status = "info|error|warn"  runner.py     import properties p     import re     line = "[time stamp] info [other information]"     print(p.status in line)     line = "[time stamp] error [other information]"     print(p.status in line) 

output:

false false 

it prints nothing false.

you need call 1 or more functions in re (not use in) use regular expression engine:

print(bool(re.search(p.status, line))) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -