String Replacer not working

Hi,

I have a column of data which contains data like 12 months, 15 months, 44 months.

I am trying to use String Replacer node to replace " months" with “” and then convert the column to numeric. However, my data output remains unaltered. In the settings am providing my pattern as “months” and Replacement text as “”.

Can anyone please guide.

Regards,
Yogi

Hi @yogeshs

Welcome to KNIME Forum. I don’t know what why it doesn’t work. But it works on my machine. See this workflow string_replacer.knwf (14.1 KB)
Screenshot from 2020-09-06 22-41-41

gr. Hans

2 Likes

hi @yogeshs
I do not know why it has this problem for you
But you can also use string manipulation with this expression:
regexReplace($column1$,"months" ,"" )
image

best
sajjad

2 Likes

@Sajjadmosaheb String Manipulation certainly works buddy but am trying to use the existing node which is supposed to do this job which does not work :frowning:

Thanks for your solution.

Yogesh.

1 Like

Hi @HansS,

Me still facing the problem :cold_sweat:

Any suggestions please?

Yogesh.

Hi

Don’t fill anything in the Replacement text. Leave it blank .
Or use the Cell Splitter node, and split on white-space.

gr. Hans

3 Likes

Another problem may be that you have “whole string” checked, I think you want “all occurrences”

2 Likes

Hi @yogeshs,

did you manage to solve it? You don’t need quotes and make sure to choose option ... all occurrences instead of ... whole string otherwise you’ll do replacement only in case entire cell is matched.

One of KNIME advantages is possibility to solve same operation/task with different node/set of nodes. I wouldn’t stick with idea “Only String Replacer needs to be used to modify strings”. So I would go with @Sajjadmosaheb suggestion and if you want you can add description in node label (users including myself usually do that) what operation/modification you have done in that node.

Welcome to KNIME Community!

Br,
Ivan

5 Likes

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