Positive/Negative lookahead with grep and perl

前端 未结 4 2285
猫巷女王i
猫巷女王i 2021-02-19 07:14

my login.txt file contains following entries

abc def
abc 123
def abc
abc de
tha ewe

when i do the positive lookahead using perl, i\'m getting t

4条回答
  •  忘掉有多难
    2021-02-19 07:49

    In your perl -ne 'print if /(?)abc\s(?!def)/' you asking perl to find abc, then space, then string shouldn't be def. This is successfully matches with def abc, because there is no def after abc here and \s matches with newline.

提交回复
热议问题