js 只提取汉字的方法

88 阅读1分钟
// 只提取汉字

GetChinese(strValue) { 

console.log("333--strValue", strValue);

if (strValue !== null && strValue !== "") {

const reg = /[\u4e00-\u9fa5]/g;

console.log("333--strVal", strValue.match(reg).join(""));  
// 333--strVal 汉子汉子

return strValue.match(reg).join("");

}

return "";

}

this.GetChinese("343erwer汉子汉子*&&^"); // 333--strVal 汉子汉子