Hàm xóa dấu tiếng Việt
unknown
javascript
4 years ago
953 B
18
Indexable
function removeVietnameseAccents(str) {
const AccentsMap = [
'aàảãáạăằẳẵắặâầẩẫấậ',
'AÀẢÃÁẠĂẰẲẴẮẶÂẦẨẪẤẬ',
'dđ',
'DĐ',
'eèẻẽéẹêềểễếệ',
'EÈẺẼÉẸÊỀỂỄẾỆ',
'iìỉĩíị',
'IÌỈĨÍỊ',
'oòỏõóọôồổỗốộơờởỡớợ',
'OÒỎÕÓỌÔỒỔỖỐỘƠỜỞỠỚỢ',
'uùủũúụưừửữứự',
'UÙỦŨÚỤƯỪỬỮỨỰ',
'yỳỷỹýỵ',
'YỲỶỸÝỴ',
];
for (const accent of AccentsMap) {
const re = new RegExp(`[${accent.substr(1)}]`, 'g');
const char = accent[0];
str = str.replace(re, char);
}
return str;
}
temp1.filter(x => removeVietnameseAccents(x['Tên tài liệu'] || '').toUpperCase().includes(removeVietnameseAccents('quy trinh').toUpperCase()))Editor is loading...