Removing all leading zeros from string

Hi everyone,

i have 2 columns like that. Now i need to do delete all zeros at the beginning of string.
Can you help me, pls ?


Capture d’écran 2022-09-14 163107

Hi @KimNgoc

Have a look around on the forum, this topic has been covered a few times with various solutions available.


Hi @KimNgoc & welcome to the KNIME forum community

Complementary to @ArjenEX’s links to solutions, please find below a workflow who is answering your question too:

The first solution is using as trick the replacement of zeros “0” by blank characters " " and then using the “stripStart” function in the string manipulation node, as follows:

replaceChars(stripStart( replaceChars($String with Leading Zeros$, "0" , " ")), " ", "0")

Much easier solution is used in the second -String Manipulation- node, based on a very simple regular expression:

regexReplace( $String with Leading Zeros$,"^0+", "")

Hope it helps.



thank u so much. It is very helpful for me ^^

Thank @aworker . It works very well ^^

1 Like

I immediately thought regex but I really like the trick with the “replace twice”
THanks for sharing @aworker

1 Like

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