javascript - Why does this reg exp always succeed for the numerics? -
I have a regular expression that searches for special characters.
When I search numbers, like 3, I always get 0, when I was expecting to get -1.
'3' Search (/ [! \ "£ \ $% ^ ^ & amp; \ * \ (\) -_ \ + = \ [\] \ {\} :: @ \" # \\ |
Any idea why this is happening?
\) -_
to all the character class between )
and _
Causes the inclusion of characters, i.e. ) * +, - / .123456789:; & lt; = & gt;? @ ABCDGGHJJLMNOPQRTUVXX [\] ^ _
. 3
Is one of them.
-
should be placed at the beginning or at the end, so that it is special In addition, \
, [
, ]
and /
, do not count as a category. There is no need to avoid anything in it.
/ [-! "£ $% ^ & amp; * () _ + = \ [\] {}:: @ '# \\ | & Lt ;, & gt; (Technically [
does not need to be avoided, but I like to save it continuously.) Also , You can match a -
in the meter if you avoid it from \ -
.)
Comments
Post a Comment