Created
November 27, 2013 17:48
-
-
Save xbill82/7680025 to your computer and use it in GitHub Desktop.
JavaScript: Fuzzy search over string
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
String.prototype.fuzzy = function (s) { | |
var hay = this.toLowerCase(), i = 0, n = 0, l; | |
s = s.toLowerCase(); | |
for (; l = s[i++] ;) if ((n = hay.indexOf(l, n)) === -1) return false; | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment