js移除字符串的中文/空格

var reg =/[\u4e00-\u9fa5]/g;
var str= " 阿达 adas 123132  一二三 ";
str= str.replace(/[ ]/g, "");//去空格
str= str.replace(reg, "");//去除中文

去两端空格

String.prototype.trim=function (){return this.replace(/(^/s*)|(/s*$)/g,'');}

 

posted @ 2019-03-14 13:10  Ananco  阅读(3263)  评论(0编辑  收藏  举报