Search code examples
regexwinmerge

Why is WinMerge ignoring one line but not the other?


I'm comparing two different files, and am using these line filters:

  • ^' - Ignore lines which start with a ' character
  • ^[ |\t]*// - Ignore lines which start zero or more spaces or tabs, proceeded by //
  • [\/\/]+.* - Ignore lines with // proceeded by any number of characters, with the only restriction being line breaks.

However, the ignore behavior seems to be inconsistent:

Why is that first case statement ignored but the second one is not?

I'm guessing it has something to do with the / in the string being assigned, but my third line filter explicitly looks for 2 // so that shouldn't be the problem...


Solution

  • [\/\/]+.* matches a / to the end of the line. [] is "anything in this group", and you are just listing the / character twice. So it does not need a second / to make a match. It is equivalent to \/.*

    (\/\/)+.* would match // to end of line (.* makes + redundant). But that is probably what you wanted. (the (), not the redundancy) It is equivalent to \/\/.*