From 5e2c3db3851409331fcee78cb2be2c2effc32537 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 17 Oct 2012 19:10:48 +0100 Subject: [PATCH] Getting ready for using RegExp for search So that we can do case insensitivity and partial matches --- core/modules/utils/utils.js | 7 +++++++ 1 file changed, 7 insertions(+) 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") {