Skip to content

Instantly share code, notes, and snippets.

@IndrekV
Forked from IlanFrumer/fuzzysearch.coffee
Created July 11, 2014 11:12
Show Gist options
  • Save IndrekV/abd893afa130f720b861 to your computer and use it in GitHub Desktop.
Save IndrekV/abd893afa130f720b861 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment