Excel Function for String Manipulation Right() - equivalent in Knime?

Hi all, I’m quite new to Knime. Trying to figure out how to extract the right most values of a string in a column. Like on in Excel would use Right(String,Number_of_characters)

So an example of my data is I have a mix of date values, some including month, and some not. But at the end of the strings are always the year written in form YYYY. So like ‘01012020’ I would like to only use the right most four character ‘2020’. And I’d like to capture the year in a new column that is added to the existing table.

Does it make sense? How can I do this in Knime, is there a node for it or?

Thanks for help.

Hi @1up, welcome to the forum.

One way to solve this problem is to use the Regex Extractor node with the expression:


This tells KNIME to look for a group of 4 digits that appear at the end of a string.


Hi @1up

And another one is to use a String Manipulation node with the expression

substr($your_column$, length($your_column$)-4)


Thank you elsamuel and JanDuo both. Will try it out!

Are parenthesis needed?

(\d{4}$) ?

If I do not use parenthesis in the expression the node is “green” without error, but there is no added column in my resulting table.

If I do not use parenthesis I get an error stating, basically, all input strings not matching the pattern or contained more groups than expected.

My input column is based on a url / file name, converted into a column using
Variable table row → Url to File Path → Column Filter

Not sure if the output from this sequence is causing an issue.

Ideas anyone?

The suggestion by @JanDuo will give you the last 4 characters in the string regardless of their type. Have you tried that?

But at the end of the strings are always the year written in form YYYY. So like ‘01012020’

This is the only information you provided that hinted at what the strings look like. The regex I gave works as expected on strings such as ‘01012020’, ‘asdf2020’, ‘qwerty2010’ , ‘2015zxcvb’.

Now you say that the column in question contains a file name/url.

If you want more suggestions, you’ll need to post some example data and a workflow. Otherwise we’ll keep going in circles.

Thank you for help and assistance, it is valued. The issue is probably at my side. Will look further and see if I can resolve the case.

Thanks again, I got it working using the substring replace function, in the string manipulation node. So I assume it was something to do with the data in the column for manipulation, that had an impact on the other methods.

1 Like

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