add Ox.escapeRegExp
This commit is contained in:
parent
520eac7a22
commit
d4954db30d
1 changed files with 9 additions and 1 deletions
|
@ -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');
|
||||||
|
};
|
Loading…
Reference in a new issue