问题
Is there a diff tool that allows me to write regular expression to remove a line from difference?
Like, see the two lines:
this.Visible = true;
Visible = true;
And can I write an expression such that if the line difference is exactly this
ignore the difference.
How do I specifically do that?
I give you one more example. Like System.Exception
and Exception
both are same for me, I don't want to show them in the diff.
回答1:
You can do this with KDiff3. See the documentation section on Preprocessor Commands.
Update: I see you have a further request that appears to need a semantic diff program. See Semantic Diff Utilities for some suggestions.
回答2:
DiffMerge from SourceGear supports this. You'll need to create a Ruleset that matches the files you are merging or edit the default Rule set. In the ruleset add patterns to the Lines to Omit property. See the Ommitted Lines property in the online help for more info.
回答3:
The best source comparing software that I ever used was Beyond Compare. With it, you could do exactly what you asked for: input a regular expression that told the software to ignore certain differences. However, it's not free.
If you really need a free applicative, you can try WinMerge. I'm not very fond of the interface, though.
回答4:
Notepad++ has a compare plugin, which is pretty configurable.
回答5:
If you can't find an existing diff tool that will do what you want, you could write your own.
Python has a diff module for writing diff-like tools, which will handle all the complexities of the diffing algorithm for you. They have an example script that will do a file diff in standard Unix diff/patch format or side-by-side HTML in 60 lines of code.
The differs in the module let you define 'junk' filters to pre-process lines to remove parts that you do not want included in the diff. These are Python functions, so you are not limited to regular expression matches.
I had a quick re-read of the documentation, and the filters only work for ignoring whole lines or individual chars, which is not what you want. However, you can easily pre-process the data you feed into the differ to remove the text you want to ignore.
回答6:
I was not able to find the feature in any software, though Beyond Compare and Araxis have this feature.
From the WinMerge wiki it looks like they won't support plugins or any such feature in new future. Too bad.
回答7:
If you know how to write JavaScript you can insert the regular expression in question into the minification portion of the Pretty Diff tool. The tool is entirely free and the code is completely open with inline documentation.
If there is a specific feature you would like added to the tool, aside from a personal customization, please let me know, and I will add it.
回答8:
Try GNU diffutils. If you are on Windows, you can have GNU diff distributed with Cygwin from www.cygwin.com.
来源:https://stackoverflow.com/questions/1948164/free-diff-tool-that-is-configurable