KOSASIH / SilkRoad

Prefer adding u flag in regular expressions JS-0117
Anti-pattern
Minor
8 months agoa year old
Use the 'u' flag with regular expressions
4811        return DIACRITICS[a] || a;
4812      }
4813
4814      return text.replace(/[^\u0000-\u007E]/g, match);4815    }
4816
4817    function matcher (params, data) {
Use the 'u' flag with regular expressions
4811        return DIACRITICS[a] || a;
4812      }
4813
4814      return text.replace(/[^\u0000-\u007E]/g, match);4815    }
4816
4817    function matcher (params, data) {
Use the 'u' flag with regular expressions
 33    str = str.replace(/đ/g, "d");
 34    str = str.replace(/Đ/g, "d");
 35    str = str.replace(/ /g, "-");
 36    str = str.replace(/“|--|”|’|\.|$|,/g, ""); 37    str = str.trim().toLowerCase(); 
 38    return str;
 39}
Use the 'u' flag with regular expressions
 29    str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, "U");
 30    str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, "Y");
 31    str = str.normalize("NFD");
 32    str = str.replace(/[\u0300-\u036f]/g, ""); 33    str = str.replace(/đ/g, "d");
 34    str = str.replace(/Đ/g, "d");
 35    str = str.replace(/ /g, "-");
Use the 'u' flag with regular expressions
 27    str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g, "I");
 28    str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g, "O");
 29    str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, "U");
 30    str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, "Y"); 31    str = str.normalize("NFD");
 32    str = str.replace(/[\u0300-\u036f]/g, "");
 33    str = str.replace(/đ/g, "d");