Javascript String delete(...args)

Description

Javascript String delete(...args)


String.prototype.delete = function(...args) {
  let s = this.valueOf();
  args.forEach(a => {//  ww w  . ja va2 s.  c  o m
    if (typeof a === 'string') {
      s = s.replace(new RegExp(`${a.replace(/([\\/'*+?|()\[\]{}.^$])/g,"\\$1")}`, 'g'), '');
    }
    else if (a instanceof Array) {
    
    }
    else if (a instanceof RegExp) {
      s = s.replace(a, '');
    }
  });
  
  return s;
};



PreviousNext

Related