Var reg=new RegExp (" [! @ # $% ^ & amp; () ` '_ :,,,,,] ")
Reg. The test (' Abc ')
Special characters in regular, literally knocked some,
But the test is a problem, as long as it contains uppercase characters can pass it, everything else is OK,
Even the same function of online example, also have this bug,
CodePudding user response:
Not to take the value
Var reg=new RegExp (" [! @ # $% ^ & amp; () ` '_ :,,,,,] ")
The console log (! Reg. The test (' Abc '))//true
The console log (! Reg. The test ('! Abc '))//false
What is your definition of a special character, it is your choice of these "! @ # $% ^ & amp; (a) ` '_ :; :; ,] ", or in addition to the upper and lower case letters and Numbers outside is special
CodePudding user response:
You are the regular string must be at least! @ # $% ^ & amp; (a) ` '_ :; :; , one of the special characters to return true,Has nothing to do with contains contains uppercase characters
Var reg=new RegExp (" [! @ # $% ^ & amp; () ` '_ :,,,,,] ")
Alert (reg. Test (' Abc& '));//true
CodePudding user response:
That is just contain these special characters and not through,I am the demo test (' Abc '), also returns false, so it was very strange
CodePudding user response: