From d4954db30dbffad9aac40cbb12518a6371c107aa Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 19 May 2012 10:36:02 +0400 Subject: [PATCH] add Ox.escapeRegExp --- source/Ox/js/RegExp.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/Ox/js/RegExp.js b/source/Ox/js/RegExp.js index 3d0d2e1d..2da70a6d 100644 --- a/source/Ox/js/RegExp.js +++ b/source/Ox/js/RegExp.js @@ -1 +1,9 @@ -// Opera doesn't like empty js files \ No newline at end of file +/*@ +Ox.escapeRegExp Escapes a string for use in a regular expression + (str) -> Escaped string + str String +@*/ +// see https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions +Ox.escapeRegExp = function(str) { + return (str + '').replace(/([\/\\^$*+?.-|(){}[\]])/g, '\\$1'); +}; \ No newline at end of file