Remove certain Characters in Starting

Hi!! Knime Experts…

I am facing some issue in following logic(in pic)…

Requirement;

Remove “0” from batch

Batch no.
00AASD1456 (2 times -“0”)
0QWER4897 ( time1-“0”)
000ALPH789 (3 times-“0”)
12345899
EAN0778
HHT0004

Required Output:

Batch no.

AASD1456
QWER4897
ALPH789
12345899
EAN0778
HHT0004

I have applied this formula:

But I am getting Output as;

Batch no.

AASD1456
QWER4897
ALPH789
12345899
EAN778(issue-removing zero after alphabets)
HHT4(issue-removing zero after alphabets)

I just want to remove n-number of “0” if it’s coming before Alphabtes…

Please guide…

Thanks in advance :blush:

Hi @ravi13,

I think you are thinking to much for your regex
regexReplace($column1$,"[0]{1,}" ,"" )
or regexReplace($column1$,"^[0]{1,}" ,"" )
if you only want to match leading 0s
is enough :slight_smile:

So basically you want to search for 0 or any character or character range in the search braket [ ]
You want to find 1 or more matches
and replace them with nothing
^=beginning of string

KNIME_project58.knwf (7.6 KB)

So you do not have to match the whole string and replace it with the part you want to keep

4 Likes

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