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:
123, 456, 80 TRUE
123, 456, 8080 FALSE
80, 123 TRUE
for this I use string manipulation and regexMatcher
this regex works perfectly in Pentaho, but not in Knime. I don’t know why. Any idea how to do it please?
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:
And this is the output:
how about following syntax in Rule Engine node?
$column1$ LIKE "*80*" => "TRUE"
TRUE => "FALSE"
Don’t have anything against regex just like simplicity more
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!
you are right. Have to read it more thoroughly
Don’t have anything against simplicity just like regex more!
Hello @armingrudd thank you very much for your help. I was close, but not close enough
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.
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 ) 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
If you ever come to Zagreb, Croatia would love a beer
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
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?
@armingrudd you are awesome!
Thanks a lot
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.