What is wrong in this fiddle.
function getMatches(data,city){
var matchArr = [];
var pattern = new RegExp("\\b("+ city +")","gi");
for (var i in data){
var searchStr = data[i].searchstr;
if(pattern.test(searchStr)){
matchArr.push(data[i]);
}
}
return matchArr;
}
I am able to match the first address object and and the last address object but i am not able to match the second one.But the second one also has the same word. Any idea why?