String.prototype.trim = function() {Luego para cualquier String hacemos:
return(this.replace(/^\s+/,'').replace(/\s+$/,''));
}
var texto = " He aquí un texto ";
texto = texto.trim(); //retorna el texto sin espacios delante o detrás
Recopilación de experiencias extraidas de la difícil vida de un obrero del software
String.prototype.trim = function() {Luego para cualquier String hacemos:
return(this.replace(/^\s+/,'').replace(/\s+$/,''));
}
var texto = " He aquí un texto ";
texto = texto.trim(); //retorna el texto sin espacios delante o detrás
No hay comentarios:
Publicar un comentario