有效地替换字符串中的所有重音字符?
native sorting gets it wrong: a b c o u z ä ö ü collation-correct would be: a ä b c o ö u ü z
str.translate()tr/…/…/, translate(), ReplaceList()
// s would be a rather short string (something like // 200 characters at max, most of the time much less)function makeSortString(s) {
var translate = {
"ä": "a", "ö": "o", "ü": "u",
"Ä": "A", "Ö": "O", "Ü": "U" // probably more to come
};
var translate_re = /[öäüÖÄÜ]/g;
return ( s.replace(translate_re, function(match) {
return translate[match];
}) );}A
料青山看我应如是
相关分类