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) //==> " .[]$: //!"
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn