// 去除字符串全部空格
str.replace( /\s*/g., "");
//去除字符串首尾空格
str.replace(/(^\s*)|(\s*$)/g, "");
//去除左边空格
str.replace(/(^\s*)/g, "");
//去除右边空格
str.replace(/(\s*$)/g, "");
用过的正则
猜你喜欢
转载自blog.csdn.net/qq_15238979/article/details/98845531
今日推荐
周排行