//截除字符串前后空格
function JHshTrim(sString)
{
var strTmp ;
strTmp = JHshRTrim(JHshLTrim(sString)) ;
return strTmp ;
}
}
//本函数用于对sString字符串进行前空格截除
// -----------------------------------------------------------------------------------
function JHshLTrim(sString)
{
var sStr,i,iStart,sResult = "";
// -----------------------------------------------------------------------------------
function JHshLTrim(sString)
{
var sStr,i,iStart,sResult = "";
sStr = sString.split("");
iStart = -1 ;
for (i = 0 ; i < sStr.length ; i++)
{
if (sStr[i] != " ")
{
iStart = i;
break;
}
}
if (iStart == -1) { return "" ;} //表示sString中的所有字符均是空格,则返回空串
else { return sString.substring(iStart) ;}
}
iStart = -1 ;
for (i = 0 ; i < sStr.length ; i++)
{
if (sStr[i] != " ")
{
iStart = i;
break;
}
}
if (iStart == -1) { return "" ;} //表示sString中的所有字符均是空格,则返回空串
else { return sString.substring(iStart) ;}
}
//4.2 本函数用于对sString字符串进行后空格截除
// -----------------------------------------------------------------------------------
function JHshRTrim(sString)
{
var sStr,i,sResult = "",sTemp = "" ;
// -----------------------------------------------------------------------------------
function JHshRTrim(sString)
{
var sStr,i,sResult = "",sTemp = "" ;
// if (sString.length == 0) { return "" ;} // 参数sString是空串
sStr = sString.split("");
for (i = sStr.length - 1 ; i >= 0 ; i --) // 将字符串进行倒序
{
sResult = sResult + sStr[i];
}
sTemp = JHshLTrim(sResult) ; // 进行字符串前空格截除
for (i = sStr.length - 1 ; i >= 0 ; i --) // 将字符串进行倒序
{
sResult = sResult + sStr[i];
}
sTemp = JHshLTrim(sResult) ; // 进行字符串前空格截除
if (sTemp == "") { return "" ; }
sStr = sTemp.split("");
sResult = "" ;
for (i = sStr.length - 1 ; i >= 0 ; i--) // 将经处理后的字符串再进行倒序
{
sResult = sResult + sStr[i];
}
return sResult ;
}
sResult = "" ;
for (i = sStr.length - 1 ; i >= 0 ; i--) // 将经处理后的字符串再进行倒序
{
sResult = sResult + sStr[i];
}
return sResult ;
}