Skip to content

Instantly share code, notes, and snippets.

@cachoimechi
Created September 24, 2012 20:38
Show Gist options
  • Save cachoimechi/3778220 to your computer and use it in GitHub Desktop.
Save cachoimechi/3778220 to your computer and use it in GitHub Desktop.
Autocomplete Fuzzy Matching
// http://dustindiaz.com/autocomplete-fuzzy-matching
var people = ['Daniel', 'Dustin', 'David', 'Damarcus', 'Russ'];
function matchPeople(input) {
var reg = new RegExp(input.split('').join('\\w*').replace(/\W/, ""), 'i');
return people.filter(function(person) {
if (person.match(reg)) {
return person;
}
});
}
@fliu7
Copy link

fliu7 commented Jun 9, 2022

"el", "us" not return anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment