This file contains 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
/* Fuzzy Search in JavaScript in 66 bytes by SpeedyNinja | |
Creates a Regex of the Form x.*y.*z.* for query xyz and tests it against the list of terms | |
*/ | |
f=t=>s=>t.filter(x=>eval("/"+s.replace(/./,"$&.*")+"/gi").test(x)) | |
/* | |
Usage: | |
var search = f(["list", "of", "search", "terms"]) | |
search("er") -> ["search", "terms"] | |
^ ^ ^^ |