本文介绍了Java的简单的String差异UTIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在找一个简单的Java的lib / src目录,突出两个字符串,区分大小写的区别。一个HTML的输出将是巨大的,但我会很高兴得到的diff的指标,是这样的:
I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive. A html output would be great, but I would be happy to get the indexes of the diffs, something like:
diff("abcd","aacd")
> [2,2]
diff("maniac", "brainiac")
> ["man",brain"] or [0,3] or something like that
我们的想法是higlight错别字或者这样的摇摆程序,由于输入shold遵循严格的约定。
The idea is to higlight typos or such in a swing program, since the input shold follow strict conventions.
推荐答案
的Apache Commons Lang中有一类称为StringUtils的其中既有差异,indexOfDifference其满足您的需求。
Apache Commons Lang has a class called StringUtils which has both difference and indexOfDifference which fulfills your needs.
http://commons.apache.org/lang/
检查出来
这篇关于Java的简单的String差异UTIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!