比较简单实用的使用正则三种版本的js去空格处理方法
发布时间:2007-11-18 作者: 来源:转载
分别去字符串前后,左边,右边空格复制代码代码如下:String.prototype.trim=function(){returnthis.replace(/^+|+$/g,"")}String.prototype.ltrim=function(){returnthis.replace(/^+/g,"")}String.prototype.rtrim=function(){returnthis.replace(/+
分别去字符串前后,左边,右边空格
复制代码 代码如下:
String.prototype.trim=function(){returnthis.replace(/^s+|s+$/g,"")}
String.prototype.ltrim=function(){returnthis.replace(/^s+/g,"")}
String.prototype.rtrim=function(){returnthis.replace(/s+$/g,"")}