Is it possible to create a regex that will find strings that DO NOT match a pattern?
java, regex
Solution
Sure thing, boss
/(?!_PROCESSED)/
This is a negative lookahead and it's supported in almost all regexp flavours
Problem
I have this situation where I need to pull a bunch of zipfiles from a server using a prebuilt SFTP client. I only want the ones that do not have `_PROCESSED` in their filename. For example, `covers.zip` would be ok but `covers_PROCESSED.zip` would not. I have a current working solution for this where I run `lsFiles()`, which returns all the filenames in the directory and then run a function that filters them based on whether they have that keyword in their filename. They are then pulled from the server. However, in the sftp client I'm using, there is also this function: `lsFiles(String pattern)`, which returns anything that matches the pattern. I want to use this function to get only the filenames I want, since this would both shorten and optimize my code a bit. The problem is, I don't know how to make a regex that will only match things if they DO NOT have the given pattern (or if this is even possible). Can someone tell me if this is possible, and if so, provide an example of how to do this?