开发者

regex: match lines that don't match sub-regex

Let's say I have a regex expression foobar and I want to find all lines in a document that contain no match to foobar. Can I do this? 开发者_如何学运维How do I do this?


^(?!.*foobar.*).+$ 

With multiline option, matches all line that does not contain foobar..


The regexp for your case can be this

^((?!foobar))$

edited:

but if you only want grep something you can use -v parameter:

grep -v foobar
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜