![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
技能
HTTAO
正在积累!!!
展开
-
js去除空格和换行的正则表达式
//去除空格 String.prototype.Trim = function() { return this.replace(/\s+/g, ""); } //去除换行 function ClearBr(key) { key = key.replace(/<\/?.+?>/g,""); key = key.replace(/[\r\n]/g, "")...原创 2018-10-09 15:24:38 · 1282 阅读 · 0 评论 -
js去空格的其他方法
1、String.trim() trim()是去掉首尾空格 2、str.replace(" ", ""); 去掉所有空格,包括首尾、中间 复制代码 代码如下: String str = " hell o "; String str2 = str.replaceAll(" ", ""); System.out.println(str2); 3、或者replaceAll(" +",&quo转载 2018-10-09 15:44:46 · 2922 阅读 · 0 评论