Trim the whitespaces at the beginning and end of a string using while loops instead of regular expressions.
function TrimString(strToTrim)
{
while('' + strToTrim.charAt(0) == ' ')
{
strToTrim = strToTrim.substring(1, strToTrim.length);
}
while('' + strToTrim.charAt(strToTrim.length - 1) == ' ')
{
strToTrim = strToTrim.substring(0, strToTrim.length - 1);
}
return strToTrim;
}