How can i implement a sublime-like fuzzy search on select2?
Example, typing \"sta jav sub\" would match \"Stackoverflow javascript sublime like\"
albertein's answer doesn't match Trevor's version because the original function performs matching on character basis and not on word basis. Here's a simpler one matching on character basis:
$("#element").select2({
matcher: function(term, text, opts) {
var pattern = term.replace(/\s+/g, '').split('').join('.*');
text.match(new RegExp(pattern, 'i'))
}
})