The best way to use filter and ignore diacritics while do searching

1,425 views
Skip to first unread message

Nomore eyes

unread,
Jun 18, 2014, 4:56:35 AM6/18/14
to ang...@googlegroups.com
Hi, I'm new to AngularJs, and stacking with the problem of diacritics while do filtering through filter:search. Here is an example what I'm talking about: http://jsfiddle.net/gFGFN/8/ to filter here I should write the full word as it is: Jamón and not Jamon. How could I avoid it? And ignore these special characters and all the diacritics?
And I can see that nobody cares about such things, all the projects I can see on GitHub have the same issue. On http://builtwith.angularjs.org there is only one website, which is really complicated and hard to understand, uses the complicated technics to avoid it: http://illicoweb.videotron.com, it has a simple JavaScript code and function in it which do str.replace using RegExp. And they implemented it in their controller. As for me it doesn't work at all.
On StackOverflow I've found this solution: http://jsfiddle.net/gFGFN/1/ it uses custom filter but it doesn't work for more complex array: http://jsfiddle.net/gFGFN/7/
So the question is how to make the simplest solution to ignore symbols like á, é, ü or ö, it doesn't matter at all which symbols. And how to make the latest filter here  http://jsfiddle.net/gFGFN/7/ to do filtering? 
What would you recommend to read? Any tips or tutorials on these complex things?
Thanks! I hope it is clear

Sander Elias

unread,
Jun 18, 2014, 7:10:28 AM6/18/14
to ang...@googlegroups.com
Hi Nomore,

You need to make an lookuptable and replace all the characters in the string with versions without diacritics. then you can do the filtering on the strings without those. Keeping both versions of the sting enables you to display with, and search without them.

Does that make sense?

Regards
Sander

Nomore eyes

unread,
Jun 18, 2014, 8:50:17 AM6/18/14
to ang...@googlegroups.com
Sorry, nothing.
I've just googled some ways to implement javascript function in controller but nothing found that would explain.
Plus as I understood your solution would make sense If I had an array like here  http://jsfiddle.net/gFGFN/7/ for example. But in my own test project I have something like that:  <td ng-bind-html="name.surname | highlight:search.$"></td> That is using for highlight text that is in "input element". 
Is there a much more simple way to make that I want? 
Reply all
Reply to author
Forward
0 new messages