Hi there, can anyone please help me in resolving this issue?
I need to remove the string & variable extension in a number column. Example:
123456DUP10
123456DUP2
123456DUP
Result is expected as:
123456
123456
123456
Which String Manipulation command should I use?
Thank you!
Xenia
1 Like
HansS
January 23, 2020, 5:50pm
2
Hi @xeniaay
Welcome to the KNIME forum Go for the the String Manipulation Node and use:
substr($column1$,0,indexOfChars($column1$,“DUP” ) )
gr. Hans
2 Likes
Hi @HansS ,
Thank you so much for your prompt response. It works!
Best regards,
Xenia
2 Likes
Hi @HansS
Sorry… I overlooked one error… This expression also produce an incorrect result for:
Example:
CD123456DUP
CD123456
Result:
C
C
Is there a way to fix the above?
Thanks!
Xenia
HansS
January 23, 2020, 6:53pm
5
Hi Xenia,
no problem: another solution is to use the String Manipulation node and do:
removeChars($column1$,“CDUP” )
This removes as C-D-U-P characters from your string.
Happy KNIME-ing.
gr. Hans
Hi @HansS
Yes, this should work to remove “DUP” at the end of the string but it doesn’t remove any possible extension # after DUP. What I want is:
Example:
CD123456DUP
CD123456DUP10
CD123456DUP 4
CD123456
Expected result:
CD123456
CD123456
CD123456
Can we make a twist to substr($column1$,0,indexOfChars($column1$,“DUP” ) )?
Thank you!
Xenia
ipazin
January 24, 2020, 8:46am
7
Hi there @xeniaay ,
welcome to KNIME Community!
So if you always want first 8 characters from your column you can use
substr ($column_name$, 0, 8)
and if you want everything before “DUP” string then I would use this function
substr ($column_name$, 0, indexOf ($column_name$, “DUP”) ).
In latter case if there is no “DUP” you will get empty string. Then you can use Rule Engine node to replace empty string with original value.
Hope this helps!
Br,
Ivan
3 Likes
system
Closed
January 31, 2020, 8:46am
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.