Applying Multiple Find-and-Replace Operations

I have multiple articles that require multiple find-and-replace operations. I used the Replace function in the String Manipulation node, but it updates the rows one by one. Instead, I need all replacements for each article to be applied collectively so that the final output keeps each article in a single row.

I’ve attached an example workflow below to illustrate my goal more clearly. Any suggestions on how to achieve this in KNIME would be greatly appreciated. Thanks!

Article Find and Replace.knwf (6.9 KB)

Try this. You’ll need to put your terms into a table to feed the String Replacer (Dictionary) node.

workflow

5 Likes

Did the workflow I posted work for you?

1 Like

Thank you! I’m currently working with an older version of KNIME that doesn’t include the String Replacer (Dictionary) node, but this makes perfect sense. I really appreciate the help!

What version of KAP are you using? Are you under corporate constraints which prevent you for upgrading to the latest 5.x version? If so, sorry; if not upgrade.

1 Like

I’m using version 4.7.8. I tried the String Replace (Dictionary) node, but it only works with exact matches. Do you have any other suggestions? Thanks for your help!

You didn’t mention this before. Do you have some examples of non-matching terms you’d like to use? Also how big are your potential article/term lists? This is probably doable with a fuzzy search, but could get very complicated. In fact if there is very little similarity between the original and replacement terms its going to be impossible to get meaningful results.

1 Like

Attached is an example of the issue I encountered when using the dictionary. The problem isn’t that the terms don’t match — it’s that the replacement only works when the term is the only content in the cell. Since the bodies of my articles are long, I need something that can find and replace multiple instances within a single cell / article body.

Article Find and Replace V2.knwf (14.5 KB)

I’m fairly certain the problem is the limitation of the deprecated node you’re using. As you’ve observed it will only replace exact matches. The new KAP 5.x version obviously works as you can see from the screenshot I posted. Is there some reason you can’t update you KAP?

2 Likes

We encountered various limitations with the newer version that we need to address before proceeding with the update. In the meantime, do you know of any other solutions or workarounds that could help resolve the issue? Thank you again for your help - it’s much appreciated!

I’m not ignoring you. I’ve been busy with personal issues. Frankly I don’t have a quick solution for KAP 4.7.x. A similarity/fuzzy solution won’t work since there’s no similarity between your terms. There may be a a way to do this with loops, but I can’t get my mind around it. Maybe other KNINERS can jump in.

1 Like

Hi @ncherpak,

I’ve used another method that includes String Manipulation, Group Loop, and Recursive Loop.

  • First, I cross-joined the tables you created.
  • Then, I applied a Group Loop for the sentence you wanted to update, recursively checking values in the dictionary and making the necessary changes.
  • The Loop End node captures all iterations, including updates.
  • Finally, a Group By node consolidates the last version of each group loop—essentially providing your final answer.

Hope this helps! Screenshots and the revised workflow are attached.

PS: I jumped in :slight_smile: @rfeigel Hope I managed to solve.

Best,

Alpay

Article Find and Replace V2 AZ.knwf (58.1 KB)

4 Likes

Hello @ncherpak
Sorry for my late answer. You may find useful to check the following topic:

BR

1 Like

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