Javascript String stripSlashes()

Description

Javascript String stripSlashes()


function now(){/*from w  w  w .  j a  v  a  2  s.  c  om*/
  return (new Date()).getTime();
}
String.prototype.stripSlashes = function(){
    return this.replace(/\\(.)/mg, "$1");
}
String.prototype.stripHTML = function(){
    return $('<p/>').html(this.toString()).text();
}

Javascript String stripslashes()

// Strip Slashes/*from w  ww  .  j av  a2  s .co  m*/
String.prototype.stripslashes = function () {
    return (this + '').replace(/\\(.?)/g, function (s,n1) {
        switch (n1) {
            case '\\':
                return '\\';
            case '0':
                return '\u0000';
            case '':
                return '';
            default:
                return n1;
        }
    });
}



PreviousNext

Related