可配置的免费 diff 工具?

发布于 2024-08-15 06:41:01 字数 264 浏览 8 评论 0原文

是否有 diff 工具允许我编写正则表达式以从差异中删除行?

就像,看到这两行:

this.Visible = true;
Visible = true;

我可以编写一个表达式,使得如果行差异恰好是 this 则忽略差异。

我具体该怎么做呢?

我再给你举一个例子。就像 System.Exception 和 Exception 对我来说都是一样的,我不想在差异中显示它们。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

瀟灑尐姊 2024-08-22 06:41:01

您可以使用 KDiff3 来完成此操作。请参阅有关预处理器命令的文档部分。

更新:我发现您还有一个似乎需要语义差异程序的请求。有关一些建议,请参阅语义差异实用程序

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.

我是男神闪亮亮 2024-08-22 06:41:01

SourceGear 的 DiffMerge 支持此功能。您需要创建与要合并的文件匹配的规则集或编辑默认规则集。在规则集中,将模式添加到要省略的行属性。有关详细信息,请参阅联机帮助中的省略行属性。

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.

尴尬癌患者 2024-08-22 06:41:01

我用过的最好的源比较软件是Beyond Compare。有了它,您就可以完全按照您的要求进行操作:输入告诉软件的正则表达式忽略某些差异。但是,它不是免费的。

如果您确实需要免费的应用程序,您可以尝试 WinMerge。不过,我不太喜欢这个界面。

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.

爱你是孤单的心事 2024-08-22 06:41:01

Notepad++ 有一个比较插件,它是非常可配置的。

Notepad++ has a compare plugin, which is pretty configurable.

北城半夏 2024-08-22 06:41:01

如果您找不到可以执行您想要的操作的现有比较工具,您可以编写自己的工具。

Python 有一个 diff 模块 用于编写类似 diff 的工具,它将处理所有复杂性为您提供差异算法。他们有一个示例脚本,可以在标准 Unix 中进行文件比较 diff/patch 格式或 60 行代码的并排 HTML。

模块中的差异允许您定义“垃圾”过滤器来预处理行,以删除您不希望包含在差异中的部分。这些是 Python 函数,因此您不限于正则表达式匹配。

我快速重新阅读了文档,过滤器仅适用于忽略整行或单个字符,这不是您想要的。但是,您可以轻松地预处理输入差异的数据,以删除要忽略的文本。

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.

北城挽邺 2024-08-22 06:41:01

我无法在任何软件中找到该功能,但 Beyond Compare 和 Araxis 有此功能。

从 WinMerge wiki 看来,他们在新的未来将不再支持插件或任何此类功能。太糟糕了。

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.

时光倒影 2024-08-22 06:41:01

如果您知道如何编写 JavaScript,则可以将相关正则表达式插入 Pretty Diff 工具的缩小部分。该工具完全免费,代码完全开放,并带有内联文档。

如果除了个人定制之外,您还希望向该工具添加特定功能,请告诉我,我会添加它。

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.

白昼 2024-08-22 06:41:01

尝试GNU diffutils。如果您使用的是 Windows,则可以使用来自 www.cygwin.com 的 Cygwin 分发 GNU diff 。

Try GNU diffutils. If you are on Windows, you can have GNU diff distributed with Cygwin from www.cygwin.com.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文