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,'');}
原文地址:https://www.cnblogs.com/shizilunya/p/10529654.html