Skip to content

Instantly share code, notes, and snippets.

@IlanFrumer
Created April 22, 2013 15:54
Show Gist options
  • Save IlanFrumer/5436254 to your computer and use it in GitHub Desktop.
Save IlanFrumer/5436254 to your computer and use it in GitHub Desktop.
Fuzzy Search
# http://stackoverflow.com/questions/9206013/javascript-fuzzy-search#answer-15252131
String.prototype.fuzzy = (search) ->
return true unless search
str = @toLowerCase()
search = search.toLowerCase()
i = 0
n = 0
l = undefined
while l = search[i++]
if ((n = str.indexOf(l, n)) == -1)
return false
true
@IlanFrumer
Copy link
Author

fuzzy search

example:
"set syntax: coffeescript".fuzzy('sscof) => true

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