Change number 2 digit from first

I want to change the data in a cell, I want to change the two most front numbers to 0, for example the data is 628012356, I want to change 62 to 0 so it becomes 080123456, this should use string manipulation,

Example data
62856939 > 0856939
62892395 > 0892395
62820502 > 0820502

please help

hi @septia1509
i’m not an expert in regex, but can try this in string manipulation node,
regexReplace($column1$,“^[62].” , “0” )
image
rgds

2 Likes

thank you for your help, it’s work

1 Like

hi @marzukim and @septia1509 ,

Unfortunately there would need to be a small modification to that regex.

Square brackets indicate the character classes that are to be considered a match, and do not indicate a sequence or the number of characters.

the [62] represents any single digit which is either a 6 or a 2.
The "." then matches any single character

As a result it will actually match the first 2 characters of any string starting with either a 6 or a 2

The following regex would match and replace the first 2 characters, provided they are “62”

regexReplace($column1$,"^62" , "0" )

2 Likes

thanks master takbb, for your regex explanation and suggestion. looks like I need a few more years to master it. :sweat_smile:
regex is like a wild beast to me … it takes time to tame!

1 Like

lol, @marzukim
Keep going, and you’ll tame the beast! (or at least it won’t bite quite so often!) :wink:

You probably know about these already, but for anybody else reading who doesn’t, the following sites are great for finding out more

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