Recon's ideas:
//-------------
Remove the space on the left side of the string
function LTrim (str)
{
if (Str.charat (0) = = "")
{
If the first character on the left of the string is a space
str = str.slice (1);//Remove the space from the string
This sentence can also be changed to str = str.substring (1, str.length);
str = LTrim (str); Recursive call
}
return str;
}
Remove the space on the right side of the string
function RTrim (str)
{
var ilength;
Ilength = Str.length;
if (Str.charat (iLength-1) = "")
{
If the first character to the right of the string is a space
str = str.slice (0, iLength-1);//Remove spaces from string
This sentence can also be changed to str = str.substring (0, iLength-1);
str = RTrim (str); Recursive call
}
return str;
}
Remove the spaces on either side of the string
function Trim (str)
{
Return LTrim (RTrim (str));
}
Rainy Day 5337 of ideas:
//----------------
function Alltrim (a_strvarcontent)
{
var pos1, Pos2, newstring;
POS1 = 0;
Pos2 = 0;
NewString = ""
if (A_strvarcontent.length > 0)
{
for (i=0; i<=a_strvarcontent.length; i++)
Recon: This sentence should be wrong, should be changed to:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.