Search code examples
regexmercurialhgignorenegative-lookbehind

Regex negative look-behind in hgignore file


I'm looking for a way to modify my .hgignore file to ignore all "Properties/AssemblyInfo.cs" files except those in either the "Test/" or the "Tests/" subfolders.

I tried using the negative look-behind expression (?<!Test)/Properties/AssemblyInfo\.cs$, but I didn't find a way to "un-ignore" in both folders "Test/" and "Tests/".


Solution

  • Python doesn't support variable-length lookbehind.

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