Reputation: 27
In this fiddle autocomplete if I type letter "s" it shows listing which starts with "s" but I need all the listing starting with "s" and having space before "s".
Means if I type "s" then i should get both kind of results like "suraj kumar" & "nimish shah". Please someone suggest me solution.
jsfiddle.net/9R4cV/701/
Upvotes: 0
Views: 92
Reputation: 736
I'm not a RegExp guru, so there might be more clever solutions, but here's an updated fiddle: http://jsfiddle.net/9R4cV/702/
source: function(req, responseFn) {
var re = $.ui.autocomplete.escapeRegex(req.term);
var matcher = new RegExp( "^" + re, "i" );
var matcher2 = new RegExp( "\\s" + re, "i" );
var a = $.grep( aTags, function(item,index){
return matcher.test(item) || matcher2.test(item);
});
responseFn( a );
}
Upvotes: 2