"use strict"; /** * RegexEscape * Escapes a string for using it in a regular expression. * * @name RegexEscape * @function * @param {String} input The string that must be escaped. * @return {String} The escaped string. */ function RegexEscape(input) { return input.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } /** * proto * Adds the `RegexEscape` function to `RegExp` class. * * @name proto * @function * @return {Function} The `RegexEscape` function. */ RegexEscape.proto = function () { RegExp.escape = RegexEscape; return RegexEscape; }; module.exports = RegexEscape;