/**
* 获取两个字符串有几个字符是匹配的
* @param source
* @param subStr
* @return
*/
private int getStringMatchLength(String source, String subStr){
int maxMatchLengthOnResult = 0;
int length = subStr.length();
for (int j = 0; j < length; j++) {
for (int k = j + 1; k <= length; k++) {
int matchLength = k - j;
if (matchLength <= maxMatchLengthOnResult) continue;
String containStr = subStr.substring(j, k);
if (source.contains(containStr)) maxMatchLengthOnResult = matchLength;
}
}
return maxMatchLengthOnResult;
}
网友评论