Javascript String escapeRegExp()

Description

Javascript String escapeRegExp()


String.prototype.escapeRegExp = function() {
 //return this.replace( /([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1" );
 return this.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};

Javascript String escapeRegExp()

String.prototype.escapeRegExp = function () {
  return this.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
};



PreviousNext

Related