I have a program that transfers files from one folder to another (and does some manipulation on those files), I am trying to create a regex to exclude certain files based on file name and extension, this also needs to support multiple entries that users enter the exclude patterns they want like - exclude pattern: thumbs.db ; donotmove.xls ; *.ini;
I have a folder with the following c:\testfolder:
test.txt
test.exe
something.jpg
other.pdf
Above should be moved (could be any file) Below should not be moved (could be anything that the user specifies in config
thumbs.db
donotmove.xlsx
The goal is to exclude unwanted files like thumbs.db, and other files that the user will want to exclude (the code is already written, I am just having trouble with the regex itself).
I have been able to create a regex that will capture thumbs.db, but I have not been able to successfully add a negative lookahead into the regex.
The regex I have is:
^[Tt][Hh][Uu][Mm][Bb][Ss]\.[Dd][Bb]$
this captures thumbs.db exactly meaning if I have a file with this name "tthumbs.db" it should not capture the file name.
first problem I have is not being able to use negative lookhead to exclude the string I have tried the following:
^(?![Tt][Hh][Uu][Mm][Bb][Ss].[Dd][Bb])$ ^(?![Tt][Hh][Uu][Mm][Bb][Ss]).(?![Dd][Bb])$ ^(?![Tt])(?![Hh])(?![Uu])(?![Mm])(?![Bb])(?![Ss])).(?![Dd])(?![Bb])$
second problem I have is not being able to correctly use capturing group to capture multiple strings in one regex, I tried to add another capture group but adding does not capture anything
^([Tt][Hh][Uu][Mm][Bb][Ss].[Dd][Bb])([Tt][Ee][Ss][Tt].[Tt][Xx][Tt])$
thnx in advance.