Javascript String trim()
method
String.prototype.trim = function() { if (!this) return this; return this.replace(/\s+/g,""); };
String.prototype.trim = String.prototype.trim || function(){ if(!this) return this; return this.replace(/^\s+|\s+$/g, ""); }
String.prototype.trim = (function() { var trimRegex = /(^\s+|\s+$)/g; return function() { return this.replace(trimRegex, ''); };//from www. j a v a2s . c om }());
// String.prototype.trim String.prototype.trim = function trim() { return this.replace(/^\s+|\s+$/g, ''); };