.NET中两个字符串的逐字差异比较 [英] Word by word diff comparison of two strings in .NET

查看:54
本文介绍了.NET中两个字符串的逐字差异比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要逐字比较两个字符串.像diff一样,但用于单词,而不用于行.

I need to do Word by word comparison of two strings. Something like diff, but for words, not for lines.

就像在Wikipedia中完成的一样 http://en.wikipedia.org/w/index.php?title=Horapollo&action=historysubmit&diff=21895647&oldid=21893459

Like it is done in wikipedia http://en.wikipedia.org/w/index.php?title=Horapollo&action=historysubmit&diff=21895647&oldid=21893459

结果是我想返回单词索引的两个数组,两个字符串中的单词索引不同.

In result I want return the two arrays of indexes of words, which are different in two string.

.NET是否有任何库/frameworks/standalone_method可以做到这一点?

Are there any libraries/frameworks/standalone_methods for .NET which can do this?

P.S.我想比较几千字节的文本

P.S. I want to compare several kilobytes of text

推荐答案

似乎我找到了所需的解决方案:

It seems I've found needed solution:

DiffPlex是.NET差异库与Silverlight和HTML差异查看器的组合. http://diffplex.codeplex.com/

DiffPlex is a combination of a .NET Diffing Library with both a Silverlight and HTML diff viewer. http://diffplex.codeplex.com/

但是它有一个错误.在"Hello-Kitty","Hello-Kitty"行中,单词"Hello"将被标记为差异.尽管不同之处在于空格符号.

But It has one bug. In those lines "Hello-Kitty" "Hello - Kitty", the word "Hello" will be marked as difference. Although the difference is space symbol.

这篇关于.NET中两个字符串的逐字差异比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆