Copy the codeThe code is as follows:
= ;
= function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};
Just one escape method is to escape those special characters.
Also, the match method is an alias for the test method.
See an example:
var str=("+.[]$://!");
(str) //==> "\+\.\[\]\$\:\/\/\!"