A dash in any position other than the first or last in the character class denotes a range of characters, just as [az] matches each lowercase letter from a to z, but [-az] matches only dashes, a and g. If you look at http : //www.asciitable.com/ , you will see that [+-/] will match any of +,-./
In addition, you do not need to avoid these characters in the regular expression, especially in the character class. As mentioned earlier, the main problem is the position of the dash in the character class.
You can fix your regular expression from
"[+-/\\*\\^\\%]"
to
"[-+/\\*\\^\\%]" ^^
or without unnecessary shielding:
"[-+/*^%]"
jlordo
source share