<script> String.prototype.trim=function(){ return this.toString().replace(/(^s*)|(s*$)/g,""); } cad=' hola '; document.write('-'+cad.trim()+'-') </script>