Why is a wildcard "*" not working in Column Expressions node? - Is this in general possible

Hi all,
I spend a lot time to find out, why a wildcard “*” is not working in the “columns expressions” node.
Therefore I have the request to you to help me with this problem or to give me an answer, if this is in general possible to realize a wildcard solution in the columns expressions node. For me it seems so, that is in general not possible and that I have to use the “Rule Engine”

I have as an example a column where the following entries are:
Test (#1)
Test (#2)
Test (#3)

Now I want search for “#” to change this e.g. to a “tbd”

I have create the following code in Column Expressions node:
if (column(“Test COL”) == “*#”) {“tbd”}
else column(“Test COL”)

Result: Its not working, I get the same enty in a new column like in the first column

I have also testes this for a simpel string e.g.:
Test(string1)
Test(string2)
Test(string3)

buts its also not working!

Many thx for your help in advanced, it makes me really crazy that this is not working! :wink:

Hi @FlowCreator, and welcome to the KNIME forum

I would use the String Manipulation node with the replace function: replace($column1$,"#",“tbd” )
gr. Hans

4 Likes

Hi HansS
thx for your fast answer :grinning:
Your idea is also a good alternative to the Rule Engine solution, but I want to have this functionality in the Column Expressions node cause I can save a lot of “string manilulation” or “Rule Engine” nodes.
Ok I have now to solutions, but to be open, I’m really disappointed about KNIME that this “simple” search method is not possible in Column Expressions node ;-(
BR
FlowCreator

1 Like

Hi @FlowCreator

That I can’t solve your question using the Rule Engine node, doesn’t mean that it is not possible in KNIME :upside_down_face:
I think somebody else in the commnity can @armingrudd @ipazin @ScottF
gr. Hans

2 Likes

Hi @FlowCreator and welcome to the KNIME forum,

the Column Expressions node is based on JavaScript syntax in which you can use regex instead of wildcard. So you can use this expression instead:

if (regexMatcher(column("Test COL"), ".*#.*")) "tbd"
else column("Test COL")

If you want to match any string which has # in it, the wildcard would be:
*#* not *#
The second one (which you have used in your expression) matches any string starting with any number of characters and ending with #.
Anyway, if you want to use the Column Expressions, you can use regex to search for patterns.

There is also an other solution regarding your issue. You can use the count() and countChars() functions to see if there are any matches:

if (countChars(column("Test COL"), "#") > 0) "tbd"
else column("Test COL")

or if you are searching for a word:

if (count(column("Test COL"), "bad word") > 0) "tbd"
else column("Test COL")

Even indexOf() and indexOfChars() functions can be used in this case:

if (indexOf(column("Test COL"), "#") >= 0) "tbd"
else column("Test COL")

Do these solve your issue or do you still think KNIME cannot handle this? :wink:

:blush:

8 Likes

Hi there @FlowCreator,

String Manipulation (Multi Column) is planned for summer release.

Stay tuned!

Br,
Ivan

4 Likes

Hello armingrudd, ipazin,
first thx for your fast and detailed answer its highly appreciated andI think I will help other users to get an clear answer.

Only that you understand me right and don’t get me wrong.
I’m a KNIME beginner since one year and I find it very complicated to learn KNIME and especially such details like I have asked. I would compare your answer with e.g. a same question to Excel and an expert answer me yes its possible but you have to learn to write Macros wiht Visual Basic then you can do it. :grin:
To be open this is absolutely unsatisfied cause I also expect that some “standard” search funtions are easy to manage in Excel or other tools.
I have so long search in the Internet and your forum to find an answer or an example, but there was nothing. In our internal training, there was no comment, that this is not possible or only with JavaScript syntax. As a proposal make this clear in the learning vidoes or better make exmaples what is possible or not

I think the advantage of KNIME is, thats its easy to use, when you understand this, this I like very much. But I really hate to search for answers for standard questions and believe me I have invest to much time til I get this answer. This is really unmotivation.

Anyway I will be happy when “String Manipulation (Multi Column)” will be available or when I will be easier to handle in “Column Expressions node”.

Til then I wish you all the best, Happy Easter, healthy time and a lot of success with KNIME :wink:

BR
FlowCreator

1 Like

Hi there @FlowCreator,

I think this is great and valuable feedback and will forward it! And if I remember well I think more users were looking for wildcard logic inside Column Expressions node and were interested in if/else logic over multiple column in one node.

Now it is your turn not to get me wrong but next time don’t spend a lot of hours searching for a solution and simply ask here! Also for finding nodes and workflow examples they are in KNIME Hub can help :wink:

Tnx and you too!

Br,
Ivan

2 Likes

Hi @ipazin,
While we are discussing interesting new features for the Column Expression node, I would like to propose to possibility to reuse the possibility to reuse within the node column created in the node.
I use very often 2 or 3 successive column expression nodes and it would be nice to be able to be able to group all in one node.

Regards,

Sébastien

1 Like

Hi there @szawadski,

I definitely agree with you that this would be pretty nice improvement for Column Expressions node. Actually there is already a ticket in system to develop above mentioned functionality. (internal reference: AP-13383). Will add +1 for you.

Tnx for engagement!

Br,
Ivan

1 Like

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