mirror of https://github.com/zulip/zulip.git
Add util.escape_regexp.
(imported from commit 3ba7caa0d444a64b228bcb5f5c658c8363ddfbf5)
This commit is contained in:
parent
a4cf528fad
commit
dc54a24766
|
@ -234,6 +234,12 @@ exports.strcmp = (function () {
|
|||
};
|
||||
}());
|
||||
|
||||
exports.escape_regexp = function(string) {
|
||||
// code from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||
// Modified to escape the ^ to appease jslint. :/
|
||||
return string.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g, "\\$1");
|
||||
};
|
||||
|
||||
exports.array_compare = function util_array_compare(a, b) {
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue