Thursday, February 23, 2012

Javascript wildcard Search in array using jQuery

function search_array(a, query_value){
 keke = $.map(a, function (value) {
  re = RegExp(query_value, "gi");
  if(value.match(re)) return value;
  return null;
 });
 return keke
}

usage :
>>> search_array(["gula", "gila", "abu"], "la")
["gula", "gila"]
which im searching for string "la"

1 comment:

  1. Toyota has issued a significant recall and apology following a major recall due to brake systems failure across their most common models. Numerous analysts think that the opportunity for Cheongsam domestic solution to ramp up and make the most of what exactly is perceived as a lower in the demand for imported things.

    ReplyDelete