Javascript String.prototype.trim(/* optional list of chars to trim*/) and String.prototype.reverse(); /*reverse a string*/

String.prototype.reverse = function(){
    return this.split("").reverse().join("");
}

String.prototype.trim = function (list) {
    var list = ' '+list;
    word=this;
    while(list.indexOf(word.substr(0,1)) > -1)    word = word.substring(1);
    word = word.reverse();
    while(list.indexOf(word.substr(0,1)) > -1)    word = word.substring(1);
    word = word.reverse();
    return word;
}

Comments

Popular posts from this blog

Using Debian on linksys NAS-200

Малко за мъката по светът.