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? 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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.