I have searched and none of the existing answers works for me. My problem is as follows:
I have this code for RegExp that searches for match and highlights matching letters starting at the frist letter:
var newvals = [], regexp = new RegExp('\\b' + search.escapeRegExp(), insensitive ? 'ig' : '');
This works fine for English/US letters, but I also have special characters from the Norwegian alphabet "æøå". Any idea how I can change this regular expression to also cover the special characters?
EDIT: After applying the tip from Sam Saint Pettersen (thank you!), I got it to display the special characters, but when I do a search, the autocomplete now only match uppercase OR lowercase letters. So if I type "Ø" it suggests all words starting with a "Ø" in uppercase, and not the words starting with "ø" in lowercase. The same happens for lowercase search. The regular letters however, displays normally both uppercase and lowercase. This problem only applies to the special characters. Any ideas?
var re = new RegExp(/[a-z\Wæøå]+/igm);
I tried it against:
Hva heter du?
Hei. Min navn er Søren!
S-Ø-R-E-N.
Jeg bor i et grønn hus og jeg også lærer japansk.
Seemed to match that. At least in http://gskinner.com/RegExr/
I think if you save your JavaScript in UTF-8, this will work. The Unicode escapes for the Norwegian letters are:
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With