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
.
So, for example:
somepath/testFile.txt
should match.somepath/testFile_test.txt
should not match.somepath/testFile.txtTEMP
should 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.
Aucun commentaire:
Enregistrer un commentaire