资源描述:
《js字符串操作大全11627》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、js字符串操作大全11627js字符串操作大全.txt人永远不知道谁哪次不经意的跟你说了再见之后就真的再也不见了。一分钟有多长?这要看你是蹲在厕所里面,还是等在厕所外面……Js字符串操作函数大全2007年07月03日01:40Js字符串操作函数大全/*******************************************字符串函数扩充*******************************************//*===========================================//去除左边的空格=====
2、======================================*/String.prototype.LTrim=function(){returnthis.replace(/(^s*)/g,"");}/*===========================================//去除右边的空格===========================================*/String.prototype.Rtrim=function(){returnthis.replace(/(s*$)/g,"");}/*=
3、==========================================//去除前后空格===========================================*/String.prototype.Trim=function(){returnthis.replace(/(^s*)
4、(s*$)/g,"");}/*===========================================//得到左边的字符串===========================================*/String.pr
5、ototype.Left=function(len){if(isNaN(len)
6、
7、len==null){len=this.length;}else{if(parseInt(len)<0
8、
9、parseInt(len)>this.length){len=this.length;}}returnthis.substr(0,len);}/*===========================================//得到右边的字符串===========================================*/String.proto
10、type.Right=function(len){if(isNaN(len)
11、
12、len==null){len=this.length;}else{if(parseInt(len)<0
13、
14、parseInt(len)>this.length){len=this.length;}}returnthis.substring(this.length-len,this.length);}/*===========================================//得到中间的字符串,注意从0开始===========================
15、================*/String.prototype.Mid=function(start,len){returnthis.substr(start,len);}/*===========================================//在字符串里查找另一字符串:位置从0开始===========================================*/String.prototype.InStr=function(str){if(str==null){str="";}returnthis.indexOf(
16、str);}/*===========================================//在字符串里反向查找另一字符串:位置0开始===========================================*/String.prototype.InStrRev=function(str){if(str==null){str="";}returnthis.lastIndexOf(str);}/*===========================================//计算字符串打印长度=============
17、==============================*/String.prototype.Lengt