JSVerbalExpressions
JSVerbalExpressions copied to clipboard
"Range out of order in character class" when trying to match common operators
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 /[-\+\*/\^]/gm
Only the order with the -
in the second index fails. Is this a bug?