See this:
Match start word:
http://blog.miroslavpopovic.com/jqueryui-autocomplete-filter-words-starting-with-term
He overrides the autocomplete filter method. I use this and it works well.
// Overrides the default autocomplete filter function to search only from the beginning of the string
$.ui.autocomplete.filter = function (array, term) {
var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(term), "i");
return $.grep(array, function (value) {
return matcher.test(value.label || value.value || value);
});
};
Match word:
Match startsWith of any word in the string.
e.g. "LHR london" is matched by "london"
var matcher = new RegExp("\b" + $.ui.autocomplete.escapeRegex(term), "i");
assert position at a word boundary (^w|w$|Ww|wW)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…