Javascript regular expression commas can be verified

use possible notation: [!-sharp $% & = +-/ * ~ ^ | @. _?]

var newPassword =",";
var reg = /^[a-zA-Z0-9!-sharp$%&=+-/*~^|@._?]+$/;
...
reg.test(newPassword) //true

should not be a comma either.
wait a minute
what"s wrong

Sep.16,2021

clipboard.png

'+' - '/'charCode:


','.charCodeAt()charCode44testtrue


clipboard.png

[] -^


- +/

- ^
clipboard.png

^[a-zA-Z0-9!-sharp$%&=+-/*~^|@._?]+$:

clipboard.png


clipboard.png


Special symbols need to be escaped

Menu