I want one of my conditions to be that an asserted string is not in a list of strings.
I'm using a decision table and in my condition cell I have
and in the param cell I have
For some reason when I have a name like Sally it doesn't match that rule. If I remove "Billy|Joe|Bob" from the param cell it matches.
I should probably mention that I'm using drools 3.0.6 I saw mention of a not matches that was added in drools 4 but for reasons I won't get into I can't upgrade.
preguntado el 24 de agosto de 12 a las 23:08
Negative look ahead is something completely different than negating an expression, that I think is what you are looking for.
I don't remember much of Drools 3, but you probably will have to use an eval expression to negate that. So your decision table cell would look like
eval( ! getFirstName().matches("($param)") )
Basically you are calling a pure java expression instead of using the provided matches operator.
You have the leading bracket out of place.
The syntax for a negative look ahead is:
However, this change alone isn't enough. You need to anchor the regex:
This regex says "match any input that no se que no contengo
Entonces, usando tu ejemplo,
^(?!.*Billy|Joe|Bob) would match any input that doesn't contain
The best solution I've found is to split this into multiple conditions. I wish I could place these all in one condition but to do that I'm pretty sure I'd need to go up to at least drools 4.
| firstName!="$param" | firstName!="$param" | firstName!="$param" | |Billy |Joe |Bob |
Note: The use of pipes in the original question was to be treated as an "or" whereas here I'm using pipes to denote cells in the table.