Using std::regex and given a file path, I want to match only the filenames that end with .txt and that are not of the form _test.txt or .txtTEMP. Any other underscore is fine.
So, for example:
somepath/testFile.txtshould match.somepath/test_File.txtshould match.somepath/testFile_test.txtshould not match.somepath/testFile.txtTEMPshould not match.
What is the correct regex for such a pattern?
What I have tried:
(.*?)(\.txt) ---> This matches any file path ending with .txt.
To exclude files that contains _test I tried to use negative lookahed:
(.*?)(?!_test)(\.txt)
But it didn't work.
I also tried negative lookbehind but MSVC14 (Visual Studio 2015) throws a std::regex_error exception when creating the regex, so I'm not sure if it's not supported or I'm using the wrong syntax.