TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
559 stars 90 forks source link

Match operator not recognized #101

Closed marknadig closed 3 years ago

marknadig commented 3 years ago

Thanks for the great library. In trying it out I found that the parser does not recognize "=~" operator for In or Match. https://commons.apache.org/proper/commons-jexl/reference/syntax.html

Same for Not version "!~", Starts With, Ends With, etc.

As a workaround I see I can create my own binary op.

TomFrost commented 3 years ago

Hi Mark! I'm afraid I chose the name "Jexl" years ago without doing enough due diligence to discover that Apache also has a library by the same name. My Jexl is not in any way related to Apache's, and does not endeavor to copy any of its syntax or functionality.

With that said, though, some of your needs are built in under different syntax. you can say "Jill" in "Jillian" and 3 in [1, 24, 3], as well as negating that grouping with ! like this: !("Fred" in "Frederick"). If you prefer the =~ and !~ syntax, these can be easily added using the addBinaryOp function. There's a great example of this in the quick start guide at the top of the readme.

Starts with/ends with functionality is super easy to implement via defining a transform function or a custom binary operator as well -- just yell if you need a hand!

Enjoy :)

marknadig commented 3 years ago

Thanks for the quick reply @TomFrost and I totally understand. Thankfully "in" works for my needs. Again, thanks for the FOSS.