search.js
/*
* 複数の文字列をAND検索で探し出したい
* 大文字小文字も区別しない
*/
var line = ["1tEst","test2","3test"];
var search_string = "teSt 2";
var match_flag = isMatchMulti(line,search_string);
function isMatchMulti(line,search_string) {
var separatorString = /\s+/;
var arrayStrig = search_string.split(separatorString);
var match = new Array();
for(var i = 0 ; i < arrayStrig.length; i++ ){
reg = new RegExp("(?=.*" + arrayStrig[i] + ")","i");
match[i] = false;
for(var j = 0 ; j < line.length; j++ ){
if(line[j].match(reg)){
match[i] = true;
}
}
}
var match_flag = false;
if(0 < match.length){
match_flag = true;
}else{
match_flag = false;
}
for(var ii = 0 ; ii < match.length; ii++ ){
if(match[ii] == false){
match_flag = false;
}
}
return match_flag;
}