I just wanted to toss out a new feature we added to our local copy. A little history... We are using the autocomplete for a country list (205 items). We got a lot of feedback from users that it was confusing to type "U" when looking for united states and have 50+ results show up because we had matchContains:true. My first thought was to tell them to remove matchContains, but the response was that it's good to have for when searching for countries like "Democratic Republic of Congo" which is the official name, but you'd probably search for "Congo" to find it (there is a "Republic of Congo" as well so, we can't just chop off the words at the start).
The resolution we came up with was to limit the match to the start of each word. It's rare you would actually want to match in the middle of a word so we figured this was the happy medium between matchContains being on or off. So we added a matchContains:"word" option function matchSubset(s, sub) { if (!options.matchCase) s = s.toLowerCase(); var i = s.indexOf(sub); // begin addition if(options.matchContains == "word"){ var regex = "\\b"+sub.toLowerCase(); var i = s.toLowerCase().search(regex); } // end addition if (i == -1) return false; return i == 0 || options.matchContains; }; I'm sure someone will easily point out a way to do it better or has a better regex, and I'd love to see what it is. I'd also love to see this in the main script so I don't have to maintain a separate one, but can naturally understand if it isn't in the scope of the plugin. Again, I'm definitely open to better ways to do this... so bring it on! Aaron Barker