replace with java snippet

Hi guys,

i would like to use the Java snippet node to replace some values in a column for example: gmbhcokg should be replace with gmbh and co kg. the Problem is that i would like to replace more than one with that: gmbhcokg, gmbh&cokg, gmbh co kg and so on should be all replaced with gmbh and co kg. the Problem that i have is that i have used more than one Java snippet but is there a way to directly Code it?


No doubt there is a way to code it in Java, but I think a Cell Replacer node is an easier way to solve this problem, as you can replace multiple strings in one go.


Hi @Aswin

thank you for that. But i forgot to Mention that i dont want to replace the whole cell, for example Canan Limited should be replaced as Canan ltd.

Do you know another way how i can solve this?


Look at Column Expression node. It has a slew of string manipulation functions.

1 Like

Indeed a Cell Replacer will probably not work here.

There may be easier methods, but here is one way to solve the problem:

KNIME_project3.knwf (16.2 KB)

1 Like

hi @Aswin,

thank you so much, this helped me a lot :slight_smile:

Hi Canan

maybe this also works.

if(c_TEXT.indexOf(“gmbhcokg”)>=0) {out_TEXT = c_TEXT.replace(“gmbhcokg”, “gmbh & co. kg”);}
else if(c_TEXT.indexOf(“gmbh&cokg”)>=0) {out_TEXT = c_TEXT.replace(“gmbh&cokg”, “gmbh & co. kg”);}
else if(c_TEXT.indexOf(“gmbh co kg”)>=0) {out_TEXT = c_TEXT.replace(“gmbh co kg”, “gmbh & co. kg”);}
else out_TEXT = c_TEXT;

1 Like

Thank you @Morpheus,

this helped me also a lot.

Kind regards,

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