Compares elements within 2 strings (character 1, character 2, separator optional)
File: Diff.js
Example Usage/* var str1 = "Tie, Mao, 55";
var str2 = "Tie, Mao, csdn"; var result = diff (str1, str2, ', '); Object var rs = "" + result; "Csdn" var df1 = result.diff1; [""] var df2 = result.diff2; ["CSDN"] *//Comparison of elements within 2 strings (character 1, character 2, separator optional) function diff (str1, str2, separator) {//str1 = STR1 | |
""; str2 = STR2 | |
""; Separator = Separator | |
",";
Arr has ele element function haselement (arr, ele) {//memory loop var hasItem1 = false; for (var i2=0; i2 < arr.length; i2++) {//var item2 = Arr[i2] | |
"";
if (!ITEM2) {continue;
}//if (ele = = item2) {hasItem1 = true;
Break
} return hasItem1;
};
function Inanotb (A, B) {//In a, not in b var res = []; for (var i1=0; i1 < a.length; i1++) {var item1 = A[i1] | |
"";
if (!item1) {continue;
var hasItem1 = haselement (b, item1);
if (!hasitem1) {Res.push (item1);
} return res;
};
var list1 = Str1.split (",");
var list2 = Str2.split (","); var diff1 = INANOTB (List1, List2);
var diff2 = INANOTB (List2, List1);
return results var result = {diff1:diff1, diff2:diff2, Separator:separator, Tostring:function () {//
var res = this["diff1"].slice (0);
res = Res.concat (this["diff2"]);
Return Res.join (this["separator"]);
}
};
return result; };
Please use as needed, I used to compare tables exported in 2 Oracle databases with those that were not successfully imported.