我有这段代码
grep -P "(?<=|^)some [a-z]+s\b" file.txt
它匹配以-s结尾的所有单词,但如果我写这个
grep -P "(?<=|^)some [a-z]+[^s]\b" file.txt
如果我有:
some girls
some girl
some guys
some guy
some apples
some apple
我想找到“一些女孩”,“一些苹果”和“一些男人”
答案 0 :(得分:1)
我认为你只想在下一个文件中带有女孩的行:
something wrong
some girl I know
some girl knows some boys
some boys know nothing
最后一个字母不应该是s:
grep -P 'some [a-z]+[a-rt-z]\b'