JSVerbalExpressions icon indicating copy to clipboard operation
JSVerbalExpressions copied to clipboard

"Range out of order in character class" when trying to match common operators

Open tommy-mitchell opened this issue 2 years ago • 0 comments

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?

tommy-mitchell avatar Jul 10 '22 04:07 tommy-mitchell