regexMatcher in Column Expressions

Hi All,
I am finding the regexMatcher inconsistent or maybe I don’t understand how regex is implemented in Knime.
I have an expression, regexMatcher(column(“MyColumn”),“F[0-9]+”) but when I run the expression I get false for below

|MyColumn|BoolCol|
|12121112 F9731.|FALSE|
|12121211 2112|FALSE|
|1212121|FALSE|
|65645454|FALSE|
|111111111 F1111|FALSE|

I am assuming you expect a match on the first and last rows; the regex matcher works on the entire string so you’d need to have something like [^F]*F[0-9]+.*

3 Likes

Yes, sorry forgot to mention am after first and last row.
Thanks for the reply,
I’m finding something strange, feels like a knime bug:

0383487076 False 1
0111111 F1111 True 1
0111100 F7777 True 1
01111 F2281 True 1
01111111 F5334 True 1
01111111 False 1

Where false, it’s suppose to show 0 based on the column expression in the 3rd column:

if (regexMatcher(column(“Service_Number”),"[^F]F[0-9]."))
{
x=1;
}else
{
x=0;
}

I only manage to get it to work correctly if I imply below in condition

if (regexMatcher(column(“Service_Number”),"[^F]F[0-9].")===“True”)

The regexMatcher function returns a String type - as it does in the String Manipulation node, for example; this is why you need do a comparison on the String representations of true and false.

2 Likes

make sense, thanks a lot

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