trim, ltrim and rtrim in javascript
13
Trim , Left trim (ltrim) and Right Trim (rtrim) in javascript
//Function to trim the space in the left side of the string
function ltrim ( s ){
return s.replace( /^\s*/, "" );
}
//Function to trim the space in the right side of the string
function rtrim ( s ){
return s.replace( /\s*$/, "" );
}
//*Function to trim the space in the string
function trim(s) {
var temp = s;
return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}






I've got good news, and I've got bad news:
The universe is merely a figment of my imagination.
Now are you ready for the bad news?