diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 2f67ad178..6ad0b3a86 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -221,6 +221,13 @@ exports.stringify = function(s) { .replace(/[\x80-\uFFFF]/g, exports.escape); // non-ASCII characters }; +/* +Escape the RegExp special characters with a preceding backslash +*/ +exports.escapeRegExp = function(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') +}; + exports.nextTick = function(fn) { /*global window: false */ if(typeof window !== "undefined") {