Replacement of Multiple character with new character


It may be very basic question and i am sorry if this has been answered before but i am struggle for some time now to solve my issue and not been able to do so.

The problem is, I have a column called “Category” which has entries A,B,C,D,E,F,G,H,I & J (10 characters). I want to reduce these to four (A,B,C & D) and want E & I to be replaced with A and F and J with B using only one node. I have used replace function, regexreplace but could not do it.

thanks in advance

Hello @Mobihashim01,

you are looking for Rule Engine node.

Welcome to KNIME Community!


1 Like

Thank you. Could you please let me know how to do. I tried using rule engine but I was failed to do so. Could you kindly give me an example for me to see what is wrong I am doing?

Hi @Mobihashim01 , welcome the the KNIME community.

Assuming I’m understanding your question…

For this specific (single letter substitution) use case, you can also use the String Manipulation node:

replaceChars($category$,"EIJ" ,"AFB" )

So whether that is useful to you depends on whether the data you have given is just for the purposes of an example, or is actually what you wish to do.

For a two node solution, which is easy to maintain if the list ever changes (and could also have a “changes” list supplied from a database/spreadsheet etc), I would go for the String Replacer (Dictionary) node.

As @ipazin suggests, the Rule Engine can also be used and supplied with a set of rules:


$category$="E" => "A"
$category$="I" => "F"
$category$="J" => "B"
TRUE => $category$

The final line is needed so that it knows to return the current value of “category” if none of the previous rules match. If you omit that line, your substitutions would occur but anything else would be returned as a missing value.

If that doesn’t work for you, post us information about what is happening when you try it.

Attached is a sample workflow with the above options

replacing values.knwf (78.1 KB)


thanks Takbb. it works. appreciate it

1 Like

You’re welcome @Mobihashim01 .

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