Remove last Number/Character of Column

Hello,

i am trying remove the last Number/Character of a Column.
I have a list of IP-Adresses, e.g.

10.20.100.1
10.20.101.1
10.30.200.1
etc.

I want to change the last digit to a zero but how?

Thanks in advance.

Hi there @Belvedere,

welcome to KNIME Community Forum!

Using String Manipulation node with this formula should replace last character with 0:

join(substr($column1$,0,length($column1$)-1),"0")

If you know regex you can use it as well :wink:

Br,
Ivan

3 Likes

Hi @Belvedere and welcome to the community!

regexReplace($column1$, "\\d$", "0")

:blush:

3 Likes

(… but if the OP is talking about making the last octet 0, maybe for doing masks (e.g 1.2.3.45 -> 1.2.3.0) then in this regex you’d need do something else like ..., "\\.\\d+$", ".0") )

3 Likes

Thank you ! :slight_smile:

1 Like

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