twitter-bootstrap-typeahead
twitter-bootstrap-typeahead copied to clipboard
Accent Insensitive Highlighting
I'd love for accent insensitive highlighting to be baked in the same way case insensitivity is. I'm currently using the following for French, and I'm not sure how it would generalize:
highlighter: function(item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
// French accent insensitivity
// ---------------------------------------
query = query.replace(/a/i, '[aáÁàÀâÂäÄ]');
query = query.replace(/e/i, '[eéÉèÈêÊëË]');
query = query.replace(/i/i, '[iíÍìÌîÎïÏ]');
query = query.replace(/o/i, '[oóÓòÒôÔöÖ]');
query = query.replace(/u/i, '[uúÚùÙûÛüÜ]');
query = query.replace(/c/i, '[cçÇ]');
// ----------------------------------------
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>';
});
}
+1
+1
+1
+1
Do you know how to adapt this "hack" to https://github.com/bassjobsen/Bootstrap-3-Typeahead
@bklups please check this out http://stackoverflow.com/questions/22460272/typeahead-insensitive-accent/35247090#35247090