I try to list all files in a directory that do not start with "Camera1", but end with ".png". For doing so, I am using a regular expression in list.files in R. To exclude "Camera1", I tried to use a negative lookahead, but it doesn't work. Where is my mistake? ;)
list.files(pathToDirectory, pattern = "^(?!Camera1).*\\.png")
I get the error: invalid 'pattern' regular expression
Thanks in advance :)
Looks like the default engine doesn't like lookarounds, so you need to use Perl. This works:
But this doesn't:
So, to do what you what you want: