Positive/Negative lookahead with grep and perl

前端 未结 4 2252
猫巷女王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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 07:46

    I would try anchoring your regex like so:

    /(^abc\s+(?!def).+)/
    

    This would capture:

    abc 123
    abc de
    

    The (?) at the beginning of your negative lookahead regex is redundant

提交回复
热议问题