Python regex to match a specific word

后端 未结 3 721
感情败类
感情败类 2020-12-30 05:32

I want to match all lines in a test report, which contain words \'Not Ok\'. Example line of text :

\'Test result 1: Not Ok -31.08\'

I tried

3条回答
  •  [愿得一人]
    2020-12-30 06:20

    Absolutely no need to use RegEx in this case! Just use:

    s = 'Test result 1: Not Ok -31.08'
    if s.find('Not Ok') > 0 : 
        print("Found!")
    

    or as already mentioned:

    if 'Not Ok' in s:
        print("Found!")
    

提交回复
热议问题