As a few people already mentioned you need to anchor your pattern. Otherwise, .* might match what you want to exclude and attempt the match after it, resulting in an unwanted result.
What your regx is doing in words is this: (.*) match anywhere GUIDE_ : normal text match (?!MIB) : immediately not followed by MIB (.*) : match anywhere (?!P4) : not followed by P4 Now, what you want to do if MIB and P4 can be anywhere after GUIDE_ is to match every character and the make sure it is not followed by any of those, up to the end. The regex for that would be: (.*)GUIDE_(?:(?!MIB)(?!P4).)*$ The fancy part at the end translates into : Make sure the following text is neither MIB or P4 when you try to match the next char, up to the end of string. it does not make a distinction weither MIB comes before or after P4. It will make sure any of those is not after GUIDE_ Richard Lavoie > On 2014-09-19, at 03:38, Jan Seidel <[email protected]> wrote: > > Hi all, > > I have a weird issue with a regular expression. > Hopefully you can help me out here. > > I have a RegEx like (.*)GUIDE_(?!MIB)(.*)(?!P4) > It should, as far as I can tell, list all jobs containing GUIDE but exclude > GUIDE jobs with a MIB in the middle or P4 at the end of the project name, > right? > > My problem here is, that jobs with a P4 at the end still are listed :( > > I have for testing purposes tried all kind of RegEx that crossed my mind but > without any success. > Later I tried just to exclude job names with a P4 at the end. No joy > > The RegEx I used was: (.*)GUIDE_(.*)(?!P4) > The list is then completely emtpy. > > Can someone tell me where I glitch? > > Cheers > Jan > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
