/*******************************************************************************************
 * Use this set of functions to trim or remove whitespace from the ends of strings. These  *
 * stand-alone functions can left trim, right trim, or trim from both sides of the string. *
 * Rather than using a clumsy loop, they use simple, elegant regular expressions.          *
 *******************************************************************************************/
function trim(stringToTrim)
  {
   // Remove leading and ending whitespaces.
   return stringToTrim.replace(/^\s+|\s+$/g,"");
  }

function ltrim(stringToTrim)
  {
   // Remove leading whitespaces.
   return stringToTrim.replace(/^\s+/,"");
  }

function rtrim(stringToTrim)
  {
   // Remove ending whitespaces.
   return stringToTrim.replace(/\s+$/,"");
  }


