String.prototype.trim = function() { var i = 0; var inicio; var fim; while ((inicio = this.indexOf(" ",i)) >= 0 && (inicio = this.indexOf(" ",i)) <= i) { i++; } inicio = i; i = this.length - 1; while ((fim = this.lastIndexOf(" ",i)) == i) { i--; } return this.substring(inicio,i+1); }; // Testando --------------------------------------------------- teste = " Renato "; trace(teste); trace("Quat. de caracteres com espaços: " add teste.length); teste = teste.trim(); trace(teste); trace("Quat. de caracteres sem espaços: " add teste.length);
[]'s