Js字符串操作数大全.doc
文本预览下载声明
Js字符串操作函数大全
/*
******************************************
字符串函数扩充
******************************************
*/
/*
===========================================
//去除左边的空格
===========================================
*/
Stotype.LTrim = function()
{
return this.replace(/(^\s*)/g, );
}
/*
===========================================
//去除右边的空格
===========================================
*/
Stotype.Rtrim = function()
{
return this.replace(/(\s*$)/g, );
}
/*
===========================================
//去除前后空格
===========================================
*/
Stotype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, );
}
/*
===========================================
//得到左边的字符串
===========================================
*/
Stotype.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);
}
/*
===========================================
//得到右边的字符串
===========================================
*/
Stotype.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开始
===========================================
*/
Stotype.Mid = function(start,len)
{
return this.substr(start,len);
}
/*
===========================================
//在字符串里查找另一字符串:位置从0开始
===========================================
*/
Stotype.InStr = function(str)
{
if(s
显示全部