使用MERGE (employer:Employer {name: $employerName})
WITH employer
UNWIND $names AS name
MERGE (employee:Employee {name: name})
MERGE (employer)-[:Employs]->(employee)
RETURN *
函数,如何在数组中搜索通配符匹配时获得正面结果,如下所示?我目前得到的只是一个负面结果:( - 1)
indexOf
答案 0 :(得分:3)
var arr = ["OTHER-REQUEST-ASFA","OTHER-REQUEST-ASFB","OTHER-REQUEST-ASFC"]
var a = arr.filter(s => s.includes("ASFB"));
console.log(a);

答案 1 :(得分:1)
var arr = ["OTHER-REQUEST-ASFA","OTHER-REQUEST-ASFB","OTHER-REQUEST-ASFC"]
var searchTerm = "ASFB";
arr.forEach(function(str, idx) {
if (str.indexOf(searchTerm) !== -1 ){
console.log(arr[idx] + ' contains "' + searchTerm + '" at index ' + idx + ' of arr');
}
});
答案 2 :(得分:0)
您需要遍历数组并将indexOf
应用于每个单独的字符串,以获得单个输出,您可以使用Array.some
,如果数组中的任何元素包含子:
var arr = ["OTHER-REQUEST-ASFA","OTHER-REQUEST-ASFB","OTHER-REQUEST-ASFC"]
var a = arr.some(s => s.indexOf("ASFB") !== -1)
console.log(a)