JScript trim

Author Johnny Josefsson on February 19, 2010 | Print | Bookmark
function trim(stringToTrim) 
{
 return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) 
{
 return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) 
{
 return stringToTrim.replace(/\s+$/,"");
}

Was this article helpful?

Yes No

Category: Scripting, JScript

Last updated on May 15, 2011 with 1370 views