Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试查找日志中不属于 InvalidArgumentException 类型的所有异常。我们的日志写出如下行:
Class: InvalidArgumentException
我尝试使用的正则表达式是:
/Class:.*(!InvalidArgument)Exception/
本质上,以 word 开头Class:,允许 class 后面不等于 InvalidArgument 的任何字符,然后包含 wordException
Class:
Exception
谢谢您的帮助。
一种消极的可能性:
/^Class:.*?(?<!InvalidArgument)Exception/
测试grep -P:
grep -P
kent$ echo "Class: foo InvalidArgumentException Class: bar NullPointerException"|grep -P '^Class:.*?(?<!InvalidArgument)Exception' Class: bar NullPointerException