Remove Zero

Hello,

i have in Excel table a code, which start with 00000 and i should remove only the first 5 Zeros and not all the zeros in the code, i tried t do it with “Column Expressions” but it removes all the zeros in the Code.
this is my Workflow. KNIME_project5.knwf (17.3 KB)

could someone help me plz.
thanks,

Hussein

Try using the replace function instead of removeChars. Also, I had to tweak the index a bit:

if (indexOf(column("PRODUCT"),"00000")==0) {replace(column("PRODUCT"),"00000","")}
else {column("PRODUCT")}

I love to use the String Replacer node for these kind of things: use a regular expression 00000(.*?) and replace it with $1.

3 Likes

Substring can also be used:
if (substr(column(“PRODUCT”), 0, 5) == “00000”) {substr(column(“PRODUCT”), 6, 20)}
else {column(“PRODUCT”)}

3 Likes

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