Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I am trying to remove leading zeros from the left of a string. I have values that look like 'GH54673045', 000005674505, MFE6453-GW, 000000000532, and 00034002GER. Could you please help me resolve this issue? I tried using the num function but it returns Null values. I also tried the Replace function but it removed the zeros in the middle. For example, 000000004230043 would return 42343 instead of 4230043
You may try something like:
if(isnum(myField), mid(myField, findoneof(myField, '123456789')), myField)
Hi, if there are no spaces in the codes you can convert all zeros to spaces, use ltrim to remove the initial spaces and convert again spaces to zeros:
Replace(LTrim(Replace('FieldName','0', ' ')),' ', '0')
You can also convert first all spaces to a non-used character and then return it back, like:
Replace(Replace(LTrim(Replace(Replace('FieldName',' ','~'),'0', ' ')),' ', '0'),'~',' ')
If after the fisrt zero will be always a number you can use:
Mid('FieldName',FindOneOf('FieldName','123456789'))
Else you can use:
Mid('FieldName',FindOneOf(Upper('FieldName'),'123456789.-_ABCDEF...')) // complete with all possible characters except zero.
another way to start at the first character other than 0:
Mid(String,FindOneOf(String,PurgeChar(String,'0')))