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