Closed achmurzy closed 4 years ago
After looking in to it and some testing, it looks like for negative number an escape character is needed to say the negative sign: '-' so the regex definition should be
const re = /^([a-zA-Z_ 0-9]*) ?([!<>=]{1,2}) ?([a-zA-Z_ \-0-9]*)$/;
I only briefly tested this for numeric features but it permits both positive and negative values
@achmurzy Thanks for catching this bug. And indeed, you are right that the current regex is wrong. It erroneously tries to create a range of characters between a space and 0, so escaping the \-
does solve the problem. I've applied your fix (and updated the dependencies), so now we have:
const re = /^([a-zA-Z_\-0-9]*) *([!<>=]{1,2}) *([a-zA-Z_\-0-9]*)$/;
I'll release a new patch, so please give it a go.
I am trying to filter two features: "'MARINE = 0, REP_AREA > 100". The first feature is parsed properly by the regex given on line 52 of src/utils.js
const re = /^([a-zA-Z 0-9]*) ?([!<>=]{1,2}) ?([a-zA-Z -0-9]*)$/;
but the second is not. If I change the first feature to "MARINE = 6", it too fails. I think there is an issue with the RHS VALUE term in the regex [...-0-9], perhaps not handling the negative sign interacting with the digits term properly? I'm not sure how to write the regex properly but if I remove the negative sign it works properly for me (since my features aren't using negative values).