mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
Add util.escape_regexp.
(imported from commit 3ba7caa0d444a64b228bcb5f5c658c8363ddfbf5)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user