Nodejs Utililty Methods Regexp Escape

List of utility methods to do Regexp Escape

Description

The list of methods to do Regexp Escape are organized into topic(s).

Method

escape()
function escapeRegExp(str) {
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
function unEscapeRegExp(str) {
    return str.replace(/\\(?!\\)/g,'');
RegExp.escape = escapeRegExp;
RegExp.prototype.escape = function(){
    var flags = (this.global ? 'g' : '') + (this.ignoreCase ? 'i' : '') + (this.multiline ? 'm' : ''); 
...
escape(text)
RegExp.escape = function(text) {
  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
};
escapeRegExp()
String.prototype.escapeRegExp = function() {
  return this.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
escapeRegExp(string)
String.prototype.escapeRegExp = function(str) {
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
escapeRegExp(string)
function escapeRegExp(string) {
  return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
escapeRegExp(string)
helpers.escapeRegExp = function(string) {
  return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
};