How to get the last 8 characters from the string value and also if there are 0s present in the starting of it ,discard them

Actually I have a String that contains 10 characters and I need to extract last 8 from it and if it contains 00 in starting than discard the 0’s also.
String is

Hi @Kunal_Jain ,

Could you try with the below Expression :


You can take the substring from 2 initially which will give you last 8 digits(your string is 10 characters), then check if that starts with 00, if yes, again take substring from 2. Attaching screenshot below

That is not confirm that the size of the string will be 10 everytime
It can vary

Hi @Kunal_Jain ,

In that case, could you try using the below Expression :



Actually This is the excel format of the column and I need to convert all in the same manner

@Kunal_Jain ,

When you would want to update the values within the Excel Data, we can go ahead with the Datatables Operations, mainly with For Each Row activity and update the value using an Assign activity with the Expression provided.

Have you tried using the combination of For Each Row and Assign activities, could you let us know what have you tried or what are you expecting ?

Actually I have not tried for each activity and I need to use it

Hi @Kunal_Jain

  • Use a read range activity to retrieve all the data from excel
  • Use a for each row activity with this
CurrentRow("Number") = CurrentRow("Number").ToString.Substring(CurrentRow("Number").ToString.Count-8).TrimStart("0"c)
  • Last use a write range to write it back to excel


Is there a way where we can use it in invoke code activity??

Hi @Kunal_Jain ,

Use the following in invoke code, by keeping the dt as in/out argument:

dt.AsEnumerable().ToList.ForEach(Sub(row) row("Number") = row("Number").ToString.Substring(row("Number").ToString.Count-8).TrimStart("0"c))


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