标签:io ar for sp on cti amp ad bs
function maxStr(str1,str2){
var arr1=str1.split("");
var arr2=str2.split("");
var maxlen=0;
var r1=0;
for(var i=0;i<arr1.length;i++){
for(var j=0;j<arr2.length;j++){
if(arr1[i]==arr2[j]){
var as=i;
var bs=j;
var count=1;
while(((as+1)<arr1.length)&&((bs+1)<arr2.length)&&arr1[as+1]==arr2[bs+1]){
count++;
as++;
bs++;
}
if(maxlen<count){
maxlen=count;
r1=i;
}
}
}
}
//alert(r1+"-"+maxlen);
return str1.substr(r1,maxlen);
}
var str1="abccadqqqe2222222222222",str2="agcadqqqde2222222222222";
//alert(maxStr(str1,str2));
标签:io ar for sp on cti amp ad bs
原文地址:http://www.cnblogs.com/cdwp8/p/4039718.html