Reputation: 31
I'm configuring a job on jenkins to exlude files on a github pushes. I want to exclude all pom.xml files, wherever the pom.xml would be located at (i.e. in the parent directory or any of the sub-directories.
Currently, this works:
(P|p)roject/[^/]+/pom.xml
(P|p)roject/[^/]+/[^/]+/pom.xml
(P|p)roject/[^/]+/[^/]+/[^/]+/pom.xml
(P|p)roject/[^/]+/[^/]+/[^/]+/[^/]+/pom.xml
this also works, however this one-liner is messy:
(P|p)roject/([^/]+|[^/]+/[^/]+|[^/]+/[^/]+/[^/]+|[^/]+/[^/]+/[^/]+/[^/]+)/pom.xml
My question: Is there a cleaner one-liner regex that would cover the parent directory and its sub-directories?
Upvotes: 1
Views: 227
Reputation:
This might work
# (?i)project/(?:[^/]*/)*pom\.xml
(?i)
project/
(?: [^/]* / )*
pom \. xml
Upvotes: 1
Reputation: 187
does following work?
(P|p)roject\/([^/]+\/)+pom\.xml
also note that you had not escaped forward slash and a dot character (.) which you should have
Upvotes: 2