Search code examples
rregexregex-lookarounds

How to grep for cases where a pattern doesn't exist without perl-like lookahead?


I'm trying to create a regular expression for when a pattern doesn't happen (specifically, I want to pull a list of folders and sub-folders from a drive, so I'm looking for anything that doesn't end in \\.[[:alnum:]]{1,4}$). Because this pattern goes into list.files, I can't use PERL-like lookahead (right?). Is there a way for me to achieve it other than first putting everything into a vector and then running a grep on it with lookahead?


Solution

  • OK, this was stupid. The answer was staring me in the face the whole time - list.dirs lists only directories, while list.files lists all files. I'm not sure why trying the former at first didn't seem to give me the result I was looking for...