JS gevorderde |
|
Dus alle values in Arr 1 moeten voor komen in een value van Arr 2?
in jou geval zou dat index 1 opleveren.
var searchVal = ["21","apr","2008"];
var tRE = new RegExp();
var targetArr = ["week van 14 april 2008","week van 21 april 2008","week van 28 april 2008"];
for(var i=0, j=targetArr.length;i<j;i++) {
for(var k=0, l=searchVal.length;k<l;k++) {
tRE = new RegExp(searchVal[k], "i");
if(!targetArr[i].match(tRE)) break;
if(k==(l-1)) alert("match found at:"+i);
}
}
var searchVal = ["21","apr","2008"]; var tRE = new RegExp(); var targetArr = ["week van 14 april 2008","week van 21 april 2008","week van 28 april 2008"]; for(var i=0, j=targetArr.length;i<j;i++) { for(var k=0, l=searchVal.length;k<l;k++) { tRE = new RegExp(searchVal[k], "i"); if(!targetArr[i].match(tRE)) break; if(k==(l-1)) alert("match found at:"+i); } }
|