String.prototype.LTrim = function() {
    return this.replace(/^\s*(.*)/gmi, "$1");
}

String.prototype.RTrim = function() {
    return this.replace(/(.*?)\s*$/gmi, "$1");
}

String.prototype.Trim = function() {
    // return this.LTrim().RTrim();
    return this.replace(/^\s*(.*?)\s*$/gmi, "$1");
}



// Exemplos de utiliza��o:
var myStr = "   Hugo Hideki Yamashita    ";
var msg  = "Tamanho da string original: " + myStr.length + "\n";
    msg += "Tamanho da string com RTrim: " + myStr.RTrim().length + "\n";
    msg += "Tamanho da string com LTrim: " + myStr.LTrim().length + "\n";
    msg += "Tamanho da string com Trim: " + myStr.Trim().length + "\n";
alert(msg);