RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function(str) {
return String(str).replace(/([.* ?^=!:${}()|[]/\])/g, '\ $1');
};
Just an escape method, which is to escape those special characters.
Also, the match method is an alias of the test method.
Look at an example:
var str=RegExp.escape(" .[]$://!");
document.writeln(str) //==> " .[]$: //!"