1. JS Remove the space of the string
// Go to the left space;
Function ltrim (s)
... {...
Return s.replace (/(^s*)/g, "");
}
// Go to the right space;
Function rtrim (s)
... {...
Return s.Replace (/(s*$)/g, "");
}
// Go to the left and right spaces;
function trim (s) ... {{{
//s.replace (//^sfe
Return RTRIM (LTRIM (S));
}
2. Remove the function of the space on both sides of the string
// Parameters: The string of mystr transmitted
// Return: String mystr
Function trim (mystr) {
While (mystr.indexof ("" == 0) && (mystr.length> 1) {) {
mystr = mystr.substring (1, mystr.Length);
} // Remove the previous space
While (mystr.lastindexof ("") == MyStr.Length-1) && (mystr.Length> 1) {) {
mystr = mystr.substring (0, mystr.Length-);
} // Remove the latter space
if (mystr == "") {{
mystr = "";
}
Return mystr;
}