Shorten a String

Hello all,

I am facing a problem at my workplace. At the moment i’m working at a project and i have to match IDs that need to look like that: 1234567890 but how i get them is 1234567890_43_dw43d
So basically, these IDs are mostly (there are rarely other lenghts but they are always numbers inly and shorter than 10 digits) 10 numbers long but come with a “tail” that needs to be removed. I already tried the String manipulator nodes and the String replacer. Either i use the wrong syntax or the nodes are not the ones i’m looking for since nothing is happening.

Additional difficulty: i can’t install Knime extensions because it’s a corporate environment, so the stock version of Knime is the only thing i have.

Any help is greatly appreciated!

Hi @Vivaldi

Welcome. How about Cell Splitter node?

gr
Hans

Hello Hans,

First of all, thank you for your reply.
I tried both cell splitter nodes, but i can’t egt it to work…
Could you bhelp me with thw settings there? the screenshot i appended is how i configured the node.

regards,

Vivaldi

Hello again,

Nevermind i solved my issue.
For anyone else reading this, my configuration is in the screenshot that solved it.

thanks again Hans :smiley:

at the end of the file, Knime appemnded columns that splitted, in my case, the string into sections where there was a _ , as i specified it as the deliminter. the number of digits the chunks may consist of are 10 as specified.

2 Likes

Hi there @Vivaldi,

glad you solved it and welcome to KNIME Community Forum!

Regarding your manipulation problem you can use Regex if familiar or for example following functions in String Manipulation node:
substr($column1$, 0 , indexOf($column1$, "_" ))

Regarding you difficulty with corporate environment you can install extensions from a local zip file. See instructions in last paragraph from here: https://www.knime.com/downloads/update

Happy KNIMEing!

Br,
Ivan

1 Like

Hi,

Instead of using Cell Splitter which produces 3 columns (or more if there are more extra parts separated with _), as @ipazin has suggested you could use a String Manipulation node with this expression:
regexReplace($column1$, "_.*", "")

Where “column1” is the column containing IDs in the raw format:1234567890_43_dw43d
The result is this:1234567890
You can append a new column or replace the existing column.

Best,
Armin

1 Like

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