From c5fdc1ab3908648106cc91c7f58eeb254d3c5a3a Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 29 May 2012 12:59:41 +0200 Subject: [PATCH] simplify escapeRegExp regexp --- source/Ox/js/RegExp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Ox/js/RegExp.js b/source/Ox/js/RegExp.js index ff35beb6..1314c27c 100644 --- a/source/Ox/js/RegExp.js +++ b/source/Ox/js/RegExp.js @@ -4,10 +4,10 @@ Ox.escapeRegExp Escapes a string for use in a regular expression str String > Ox.escapeRegExp('foo.com/bar?baz') 'foo\\.com\\/bar\\?baz' - > new RegExp(Ox.escapeRegExp('foo.com/bar?baz')).test('foo.com/bar?baz') + > new RegExp(Ox.escapeRegExp('/\\^$*+?.-|(){}[]')).test('/\\^$*+?.-|(){}[]') true @*/ // see https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions Ox.escapeRegExp = function(string) { - return (string + '').replace(/([\/\\\^\$\*\+\?\.\-\|\(\)\{\}\[\]])/g, '\\$1'); + return (string + '').replace(/([\/\\^$*+?.\-|(){}[\]])/g, '\\$1') }; \ No newline at end of file