Regex negative look-behind in hgignore file

I am looking for a way to modify the .hgignore file to ignore all the "Properties / AssemblyInfo.cs" files except those that are in the subfolders of "Test /" or "Tests /".

I tried to use an expression of negative appearance (?<!Test)/Properties/AssemblyInfo\.cs$, but I did not find a way to “ignore” in both the “Test /” and “Test /” folders.

+3
source share
3 answers

Python does not support variable length lookbehind.

But it \b(?<!Test)(?<!Tests)/Properties/AssemblyInfo\.cs$should work.

+2
source

, : , , , , .

, hg add . svn cvs, mercurial add , .hgignore - .

.* .hgignore, hg add , .

.hgignore, :

/Properties/AssemblyInfo\.cs

:

$ hg add Test/Properties/AssemblyInfo.cs
$ hg add Tests/Properties/AssemblyInfo.cs

, find, , , , .

+2

Usually you just do Tests?, but since dynamic backtracks are not allowed depending on the regexp mechanism, you can simply use two branches:

(?<!Test|Tests)/Properties/AssemblyInfo\.cs$

0
source

Source: https://habr.com/ru/post/1738479/


All Articles