Exact two digits number in string


I would like to ask you for a small help.

I have data in following format and I would like to return back true/false if there is number 80 (exactly two digits) in particular string. Please follow the example bellow:

$Ports$ $Contains$
123, 456, 80 TRUE
123, 456, 8080 FALSE
80, 123 TRUE

for this I use string manipulation and regexMatcher
regexMatcher($Ports$, “^.\b(?=\d{3}\b)(443)\b.”)

this regex works perfectly in Pentaho, but not in Knime. I don’t know why. Any idea how to do it please?

Hi @sm0lda,

First of all, you need to know that the backslash in your expression should be escaped. But I did not understand the relation between your question and the regex you are using. Here is the expression to do what you have asked for:

regexMatcher($column1$, ".*(?<!\\d)80(?!\\d).*")

And this is the output:




Hi there,

how about following syntax in Rule Engine node?

$column1$ LIKE "*80*" => "TRUE"

Don’t have anything against regex just like simplicity more :smiley:


Hi @ipazin,

The wildcard you have suggested will produce true matches for “123, 456, 8080” or anything similar to this. It’s not just having 80 in the string, this number must be a solo number in the string.

Actually it is possible to use the Rule Engine node as well, but not without regex! :wink:



Hi @armingrudd,

you are right. Have to read it more thoroughly :slight_smile:


1 Like

Don’t have anything against simplicity just like regex more! :sweat_smile: :wink:


Hello @armingrudd thank you very much for your help. I was close, but not close enough :slight_smile:

Now it works accordingly. I had already the solution with wildcard (same as @ipazin), but as you said it gave me back 8080 as well and that is not acceptable and I was not able to modify regex properly.

1 Like

Hi there!

Glad it works with regex but as you said it is not easy to modify it and if you leave work to someone else who isn’t familiar with it could be a problem. So got a bit more sleep and cup of coffee and here are two solutions (hopefully :smiley: ) without regex.

First couple of rules in Rule Engine which should cover examples given:

$column1$ LIKE "80" => TRUE
$column1$ LIKE "80,*" => TRUE
$column1$ LIKE "*, 80,*" => TRUE
$column1$ LIKE "*, 80" => TRUE

Or String Manipulation node with following function:

count(replace($column1$,"," ," " ),"80","w")

followed by Rule Engine if 1 and 0 are not enough.



wow, great job, I would invite you for a beer, but i have no idea where do you live :slight_smile:


If you ever come to Zagreb, Croatia would love a beer :smiley:

1 Like

Nice. I like Croatia. I’ve been to Croatia first time in 1991. Once again thank you for your help and I think I write soon again :slight_smile:


Hello @armingrudd

thank you for you regex evaluation. Now I realize it would be nice to have another evaluation which could create a new column for example “other ports” and evaluate if in number string 123. 456. 80 occurs some numbers different from 80 or 443. Evaluation of existing 80 or 443 was done and thanks for it.

Thank you so much!


Hi, I do not understand fully…quote: evaluate if in number string “123. 456. 80” occurs some numbers different from 80 …yes in this string are also different numbers than 80 or 443. Does matter which of the numbers is considered or it could be any number in the string? Or does the string have always the same format?


regexMatcher($column1$, ".*(?!80|443)\\b\\w+.*")


@armingrudd you are awesome!

Thanks a lot

1 Like

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