[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Supplement:
Copy codeThe Code is as follows:
Eval ("str = str. replace (/" + getStr + "/g ,'')");
Many people may want to write str = str. replace (/getStr/g, ") in this way, but the result is wrong. Why? In this sentence, the expression matches the getStr string instead of the first letter pointed to by getStr. The eval method can be used to avoid this problem (first, getStr gets the first letter to which it points, and uses a string to connect "str = str. replace (/"+ getStr +"/g, ")", and finally execute this code in eval, that is, explain the Javascript code first, and then execute it ).
Because of the poor eval performance, error-prone and poor readability. We recommend that you change eval ("str = str. replace (/" + getStr + "/g,") ":
Str = str. replace (new RegExp (getStr, "g "),"")