"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:

javascript
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.):

javascript
new VerEx().anyOf(["-", "+", "*", "/", "^"])
// VerbalExpression /[-\+\*/\^]/gm

Only the order with the - in the second index fails. Is this a bug?

Source: VerbalExpressions/JSVerbalExpressions