General Interface is an open source project hosted by the Dojo Foundation

Trim the left and right whitespace of a string

Trim the leading and trailing whitespace from the string value passed. The code is setup to be included in a package titled "utils", change the package name on the declaration line to add it to any other package.

trimStr
/**  
 * Remove leading and trailing whitespace from the passed string.
 * @param tr {String} value to be trimmed.
 */
utils.trimStr = function(str) 
{
  return str.replace(/^\s+|\s+$/g, '');
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.