Js 字符串操作函数大全 /* ****************************************** 字符串函数扩充 ****************************************** */ /* =========================================== //去除左边的空格 =========================================== */ String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); } /* =========================================== //去除右边的空格 =========================================== */ String.prototype.Rtrim = function() { return this.replace(/(\s*$)/g, ""); } /* =========================================== //去除前后空格 =========================================== */ String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } /* =========================================== //得到左边的字符串 =========================================== */ String.prototype.Left = function(len) { if(isNaN(len)||len==null) { len = this.length; } else { if(parseInt(len)<0||parseInt(len)>this.length) { len = this.length; } } return this.substr(0,len); } /* =========================================== //得到右边的字符串 =========================================== */ String.prototype.Right = function(len) { if(isNaN(len)||len==null) { len = this.length; } else { if(parseInt(len)<0||parseInt(len)>this.length) { len = this.length; } } return this.substring(this.length-len,this.length); } /* =========================================== //得到中间的字符串,注意从0 开始 =========================================== */ String.prototype.Mid = function(start,len) { return this.substr(start,len); } /* =========================================== //在字符串里查找另一字符串:位置从0 开始 =========================================== */ String.prototype.InStr = function(str) { if(str==null) { str = ""; } return this.indexOf(str); } /* =========================================== //在字符串里反向查找另一字符串:位置0 开...