[英]Java regex to match pattern with exceptions
My Jenkins task searches the console output to see if the build is stable. 我的Jenkins任务搜索控制台输出以查看构建是否稳定。 It searches this java pattern:
exception|error|warning|Segmentation
它搜索以下Java模式:
exception|error|warning|Segmentation
I have a compile parameter that has -Werror=format-security
in it, so Jenkins should not match it. 我有一个包含
-Werror=format-security
的编译参数,因此Jenkins不应该与它匹配。 I try this [exception|error|warning|Segmentation][^Werror]
but it still finds Werror in the text. 我尝试使用此
[exception|error|warning|Segmentation][^Werror]
但仍在文本中找到Werror。 How can I make it so it doesn't think my build is unstable because of compile parameter? 我怎样才能使它不会因为编译参数而使我的构建不稳定?
You may use 您可以使用
^(?!.*Werror).*(?:exception|error|warning|Segmentation)
See the RegexPlanet demo . 请参阅RegexPlanet演示 。
Details 细节
^
- start of string ^
-字符串开头 (?!.*Werror)
- there must not be a Werror
substring anywhere on the line (?!.*Werror)
-行上的任何地方都不能有Werror
子字符串 .*
- any 0+ chars other than line break chars as many as possible .*
-尽可能多的0+个除换行符以外的字符 (?:exception|error|warning|Segmentation)
- one of the values inside the non-capturing alternation group. (?:exception|error|warning|Segmentation)
-非捕获交替组内的值之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.