How to extract a specific text inside a string in a new column

Dear all,

I would like to extract a specific text inside a string to a new column

Example : I’m very happy about this new attribute
Text to extract : Attribute
Result in the new column : Attribute

Do you have a nod in mind by any chance ?

Thanks in advance for your help

Hello @Bongregory,

and welcome to KNIME Community forum!

Do you have a list of text you need to extract from each row or rules this specific text follows? From experience it’s always best to share some example input data and desired output with logic explained if not obvious.

Br,
Ivan

Hello @ipazin
Thanks a million for your quick answer

With a great pleasure. Please let me maybe rephrase it a bit. I need for each of my row to select only a term as " pull" and to add it in a new column. However the place is not the same in each lines. Furthermore I would like to apply this node to another terms than only “pull”

Column 2
1 Huggies pull UPS Learning Designs
2 Huggies dry and pull Disney Baby
3 Huggies Little Movers Slip pull on

New Column
1 pull
2 pull
3 pull

Hope it clarifies :slight_smile:
Best

Greg

1 Like

I am not sure whether I get this correctly. If it’s always the same word then you could write a constant column. If you want to check whether it’s included in the sentence you could probably use rule engine, regex or maybe string manipulation node for that.
BR

Hello Daniel,

Yes this is always the same words and I want to copy it in a new column. Then, could you please help me to understand how to write a constant column.

Best

Greg

Hi Greg
there is a constant column node which should allow you to write a value into a new column
constant

Give this a try
best regards

Hello Daniel

I’m more looking for the Knime equivalent to the “Find” function in excel and a way to add the speficic text to a new column

you might want to try the string replacer node

Hi @Bongregory

Try this.

1 Like

Hey There,

Please find maybe a more understandable example of what i need

Example.xlsx (9.5 KB)

Best

Greg

Hello @Bongregory!

regex seems appropriate in this case. So here is expression used in above mentioned String Manipulation node that extracts word before Kit together with Kit itself:

regexReplace($Column B$,".*?(\\w+\\sKit).*" ,"$1" )

Br,
Ivan

1 Like

Thanks a million @ipazin for your help

Best

Greg

1 Like

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