js去掉字符串中的数字或字母

张闲生 / 2023-08-24 / 原文

let  str = "123abc";
str.replace(/[a-zA-Z]+/g,"");    //去掉字母
str.replace(/[0-9]+/g,"");    //去掉数字