Substring: How to remove last two element from a string?


I want to keep only the numerical digits after the rpa operation. The numeric is dynamic so I want to remove the last two alphabets of the string.

How can I do it?

Expected output

@Tanzill_Ahsan - In the For Each DataTable …please try the below.

 Row("Balance") = Row("Balance").replace("Dr").tosting
1 Like

through an assign activity?

Yes…Through Assign activity

Hi @Tanzill_Ahsan
you can try the regex way of doing it in assign activity

row(“Balance”)= System.Text.RegularExpressions.Regex.Match(row(“Balance”).ToString,“[\d.,]+”).Value.ToString


Nived N
Happy Automation

1 Like

thank you

1 Like

@NIVED_NAMBIAR - Just checking …Do we need comma(,) inside the square brackets right…

Hi @prasath17

I think yes , we require that it seems

I think I didn’t consider the , in my input data

Let me correct in my response

Thank you @prasath17 for correcting mistake

1 Like

this is not working because of COMMA, but if I remove the comma then it working fine

Getting this error

@Tanzill_Ahsan - Apologize for the incorrect code shared…please try as below…


If you also get Cr for Credit then the above code won’t work…so you have add another replace like below…or you can try @NIVED_NAMBIAR solution too…


His solution is not working while the string contains a comma

@Tanzill_Ahsan - He did fixed the code above…please verify…

@prasath17 I will check his corrected code but how can I remove the comma from the string after removing Dr and Cr?

Thanks, your current command is working

@Tanzill_Ahsan - Just add another .replace in the same code,


@prasath17 @NIVED_NAMBIAR

Thank you so much regarding this help.

1 Like

@Tanzill_Ahsan - just another hint…

After writing the output , you will see below Ignore error like this…


If you like to ignore that, convert your output to double as shown below…

1 Like

this is a really great help but I don’t know why this is not printing the result if I am using a readcell activity


While I am using read cell activity the output is not showing and there is no error. Why this is happening?


This is not working for each loop. If I am using read cell activity, this is not showing any result.

How may I solve this problem?