"Range out of order in character class" when trying to match common operators
Author: tommy-mitchellCreated Jul 10, 2022Updated Jul 10, 2022
I'm trying to build a verbal expression to match common math operators:
new VerEx().anyOf(["+", "-", "*", "/", "^"])However, arranging the characters in this order yields the error:
Invalid regular expression: /[\+-\*/\^]/: Range out of order in character class
Any other grouping works correctly (e.g, with the - first, third, etc.):
new VerEx().anyOf(["-", "+", "*", "/", "^"])
// VerbalExpression /[-\+\*/\^]/gmOnly the order with the - in the second index fails. Is this a bug?
Source: VerbalExpressions/JSVerbalExpressions