Created
September 24, 2012 20:38
-
-
Save cachoimechi/3778220 to your computer and use it in GitHub Desktop.
Autocomplete Fuzzy Matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"el", "us" not return anything