码迷,mamicode.com
首页 > Web开发 > 详细

js 去除空格与换行

时间:2014-07-02 21:16:23      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   cti   io   type   

js 去除空格与换行

//去除空格 
String.prototype.Trim = function() 
{ 
  return this.replace(/\s+/g, ""); 
} 
//去除换行 
function clearBr(key) 
{ 
    key = key.replace(/<\/?.+?>/g,""); 
    key = key.replace(/[\r\n]/g, ""); 
    return key; 
} 

//去除左侧空格 
function LTrim(str) 
{ 
return str.replace(/^\s*/g,""); 
} 
//去右空格 
function RTrim(str) 
{ 
return str.replace(/\s*$/g,""); 
} 
//去掉字符串两端的空格 
function trim(str) 
{ 
return str.replace(/(^\s*)|(\s*$)/g, ""); 
} 
//去除字符串中间空格 
function CTim(str) 
{ 
return str.replace(/\s/g,‘‘); 
} 
//是否为由数字组成的字符串 
function is_digitals(str) 
{ 
var reg=/^[0-9]*$/;//匹配整数 

return reg.test(str);   
} 

 

js 去除空格与换行,布布扣,bubuko.com

js 去除空格与换行

标签:style   blog   color   cti   io   type   

原文地址:http://www.cnblogs.com/konghou/p/3819029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!