Regular Expression Combining Does not start with AND a contains in same group

Help!

I want to say first that I am pretty new to regular expressions. I have played with them a bit but I am no where from an expert on full understanding.

What I want to do is I want to create a group that does two separate functionalities when searching a PDF File name:

1) Does Not Contain "Confirm"
2) Starts with "SOW" OR "[TEST] SOW"

This means if a PDF named "SOW TEST Confirm REPORT.PDF" OR "[TEST] SOW TEST Confirm REPORT.PDF" it would be excluded but if it was named "SOW TEST REPORT.PDF" OR "[TEST] SOW REPORT.PDF" it would be included.

Here is what I have written and it works when I remove the negative "Does not contain Confirm" but when I add it in, no matter how it either hangs (never does it) or it does it in a way that makes everything negative.

Start at the beginning of the string. Then either (a) it must be the beginning of the string followed by C:/Users/All Users/TEST\SOW and stuff and .pdf, or (b) it must be the beginning of the string followed by C:/Users/All Users/TEST\[TEST] SOW and stuff and .pdf. Then there is more stuff and the end of the string.

Start at the beginning of the string. There must not be either (a) Confirm and stuff and .pdf, or (b) the beginning of the string followed by C:/Users/All Users/TEST\SOW and stuff and .pdf, or (c) the beginning of the string followed by C:/Users/All Users/TEST\[TEST] SOW and stuff and .pdf; after all that there's a single character. Repeat the previous sentence zero or more times until the string ends.

See how that means "not be either (a) or (b) or (c)"? That's because the (?!) works on everything in there. (?!a|b|c) means neither a nor b nor c.

Start at the beginning of the string. Then either (a) there is no Confirm and stuff and .pdf, or (b) the beginning of the string followed by C:/Users/All Users/TEST\SOW and stuff and .pdf, or (c) the beginning of the string followed by C:/Users/All Users/TEST\[TEST] SOW and stuff and .pdf. Then there is more stuff and the end of the string.

It's better than the second one but is still a far cry from being correct.

Let's start over from scratch.

String starts with that initial path, right?

Code:

^C:/Users/All Users/TEST\\

Next it has to be either SOW or [TEST] SOW. Or in other words, an optional [TEST] followed by SOW.

Code:

(\[TEST\] )?SOW

Then stuff until the .pdf extension, and the end of the string.

Code:

.*\.pdf$

All together

Code:

^C:/Users/All Users/TEST\\(\[TEST\] )?SOW.*\.pdf$

Now we can add in the bit about not containing Confirm. If it's in the string anywhere it must be after the path and SOW prefix.

Code:

^C:/Users/All Users/TEST\\(\[TEST\] )?SOW (?!___).*\.pdf$

But what to put in there? If you put Confirm then all you're doing is saying that it can't be immediately after SOW. Which is wrong. You have to say that Confirm cannot appear at that point or anywhere after.
There is no "not at this point or anywhere after" operator in regular expressions. It's only "not at this point". You have to use that to say "not at this point, and not at this point, and not at this point..." until the end. Which means repeating.

Code:

^C:/Users/All Users/TEST\\(\[TEST\] )?SOW ((?!___))*.*\.pdf$

Now if you put Confirm it will repeat that test over and over, which is good except nothing actually changes after each test. The regex has to advance. That means using a dot to match a character. Not in the (?!) because you want "not Confirm", and not "not Confirm and a character", but in the repetition part.

Code:

^C:/Users/All Users/TEST\\(\[TEST\] )?SOW ((?!Confirm).)*.*\.pdf$

Except now there's that .* still in there. The Confirm won't be in the ((?!)) part but it could be in the .* part. Since you already have a sort of .* with the negation you can get rid of the original .*