Java:使用Google-diff-match-patch

时间:2017-11-08 19:46:32

标签: java google-diff-match-patch

使用google-diff-match-patch比较差异的2个字符串。它在大多数情况下都能正常工作,除非单词中的第一个字符相同。

对于Ex:

Text1 = CHICAGO IL
Text2 = COLUMBUS OH

输出:

deltas: [Diff(EQUAL,"C"), Diff(DELETE,"HICAGO IL"), Diff(INSERT,"OLUMBUS OH")]
<span>C</span><span class='SS_ChangeDelete'>HICAGO IL</span><span class='SS_ChangeAdd'>OLUMBUS OH</span>

期望的输出:

deltas: [Diff(DELETE,"CHICAGO IL"), Diff(INSERT,"COLUMBUS OH")]
<span class='SS_ChangeDelete'>CHICAGO IL</span><span class='SS_ChangeAdd'>COLUMBUS OH</span>

任何建议或者是否有其他图书馆可以做到这一点?在此先感谢

0 个答案:

没有答案