Reputation:
In the string below, I want to split the string separated by "|" (which i can do)and would then like to compare the first part and the boolean part of each such string with the same parts of another string.
var str = "Jacobs21]2]0]Ronan]false|Tom]2]0]Joseph]true|Jacobs21]2]0]NAME$$ALL]false|";
Jacobs21]2]0]Ronan]false
is one string and so on.Jacobs21
part of this string and the boolean value appearing at its end which is "false" here.Jocobs21false
and similarly, for the another string tomtrue
and make a comparison and see if there are any similar matches?Upvotes: 0
Views: 1164
Reputation: 15847
var detailsArray = str.split("|");
var res = [];
for (var i = 0; i < detailsArray.length - 1; i++) {
finalArray = detailsArray[i].toString().split("]");
var name = finalArray[0];
var booleanString = finalArray[4];
res[i] = name.concat(booleanString);
}
for (var j = 0; j < res.length - 1; j++) {
if (res[i] == res[i + 1]) {
//do your stuff
}
}
Upvotes: 2