Positive/Negative lookahead with grep and perl

前端 未结 4 2272
猫巷女王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

    grep does not include the newline in the string it checks against the regex, so abc\s does not match when abc is at the end of the line. chomp in perl or use the -l command line option and you will see similar results.

    I'm not sure why you were making other changes between the perl and grep regexes; what was the (?) supposed to accomplish?

提交回复
热议问题