Preface:
Some time ago, we tested the following special symbols. The javascript code is as follows:
['~! @ # $ ^ & * () = | {};: '"., [\]./? ~ @ # & * {}]
The result shows that \ cannot be matched, so the code is corrected
['~! @ # $ ^ & * () = | {};: '"., [\]./? ~ @ # & * {}]
The result shows that an error occurred while running the code in JS !!!
----------------------------------------------------------
Cause:
The symbol here does not match "\" at all,
The "[\]" shown below matches "]"
The following are two rules in the regular expression.
① […] Match any character in brackets
② "\" + Actual characters \. * +? | () {}^ $ For example: \ matched character "\"
Because the "]" that appears in the middle cannot be interpreted as an explanation, you must add an escape character before it to use it as a symbol.
Bytes -------------------------------------------------------------------------------------
Summary
1. Pay attention to escape characters in Javascript, because JavaScript will not be the same as Java. If you do not need to escape characters, an error will be reported.
Example:
If so
['~! @ # $ ^ & * () = | {};: '"., [\]./? ~ @ # & * {}]
Or
['~! @ # $ ^ & * () = | {};: '"., []./? ~ @ # & * {}]
Will invalidate the entire JS segment !!
2. Check whether the \ character is an escape !!!