add Ox.escapeRegExp

This commit is contained in:
rolux 2012-05-19 10:36:02 +04:00
parent 520eac7a22
commit d4954db30d

View file

@ -1 +1,9 @@
// Opera doesn't like empty js files /*@
Ox.escapeRegExp <f> Escapes a string for use in a regular expression
(str) -> <r> Escaped string
str <s> String
@*/
// see https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions
Ox.escapeRegExp = function(str) {
return (str + '').replace(/([\/\\^$*+?.-|(){}[\]])/g, '\\$1');
};