Rule Engine Function LIKE is case sensitive? & MATCHES is case insensitive?

Hi everyone,

I am a new to KNIME platform.
I would like confirm on the rule engine functions ‘LIKE’ and ‘MATCHES’. about their case sensitivity.
In my case I have a column with aloha numeric codes such as PCPO02BAY533 , and I am checking occurrences of PO in the string, if matched it will be assigned to a category name. for now I am using LIKE function with this “PO” search.

Please help to provide your suggestions and right way in above scenario. Thanks

Hello,

LIKE and MATCHES in KNIME’s Rule Engine is case sensitive and require a * otherwise it will try to match exactly what is in the cell to your search.

If you’re worried about casing, simply uppercase your entire column using the String Manipulation node: upperCase($column1$)

and then run your rule engine with LIKE:

$column1$ LIKE “PO” => 1 will not find a match with PCPOX or POX

VS

$column1$ LIKE “*PO*” => 1 will find a match with PCPOX and POX

You can see an example of how to use LIKE in the “description” pane once you click on the Rule Engine node as well:

An alternative is Regex (Regular Expressions)

You can also use regexMatcher or regexReplace within the String Manipulation node:
regexMatcher($column1$, “.*(PO).*”)

The Operator MATCHES is based on regular expressions:
$column1$ MATCHES “.*PO.*” => 1

4 Likes

Thank you Victor,
I am going with uppercasing the column and then running a match.
I have applied rule engine (dictionary).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.