用正则表达式将Jenkins职位排除在外 [英] Exclude Jenkins jobs from view with regular expression
问题描述
我们在Jenkins的视图中使用正则表达式包含作业.
目前,示例"视图的正则表达式为example_(.+)
.
We're using regular expressions to include jobs in our views for Jenkins.
At the moment the regular expression for the "example"-view is example_(.+)
.
但是,我们刚刚添加了一个名为"example_example2"的新项目,现在该项目的作业也出现在示例"视图中.
是否有任何正则表达式从"example"视图中排除"example_example2" -job?我一直在尝试使用^
,但没有成功.
However we just added a new project called "example_example2" and now the jobs from this project also appear in the "example" view.
Is there any regular expression to exclude the "example_example2"-jobs from the "example"-view? I have been trying to use ^
but no success.
你能帮帮我吗?
推荐答案
您可以将example_
而不是example2
后面跟在字符串位置的末尾(使用负前瞻)进行匹配:
You may match example_
not followed with example2
followed with the end of string position using a negative lookahead:
example_(?!example2$)(.+)
^^^^^^^^^^^^^
如果需要锚定样式,请在开始处添加^
. .+
将匹配换行符以外的任何1个或多个字符,直到行尾为止.
In case you need to anchor the pattern add ^
at the start. .+
will match any 1 or more characters other than line break chars up to the end of the line.
在线查看 regex演示.
这篇关于用正则表达式将Jenkins职位排除在外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!