Removing the first numbers in a string


Hi Im trying to remove the 1st 2 numbers in my list but i cant seem to make it work i always get a null value whenever i use a substring(0, str-2) function i even tried remove but what it removes is the last 2 digits of my numbers my sample number is 0420 and i want to remove the 04 and get the 20.

Help is greatly appreciated I have been stuck in this problem since 2days ago.


Hey @Arvin_Gabriel_Mari_A

You can do this with String.Remove().

String str_data= "0420";
String new_data = str_data.Remove(0,2) 



HI @Arvin_Gabriel_Mari_A,
You can go by @aksh1yadav’s solution if you want to remove.
Else you can try with the sub string as follows:

It will give you the result excluding the first two characters/numbers.
Hope it helps.


Hello, I have a similar requirement. I am reading (1,00) such value into a variable and i want to use only 1 out of the string and ignore the zeroes. how can i use Sub-string in this case?

Thanks !!



Split based on colum and get the first element

str B= stra.Split({","},StringSplitOptions.RemoveEmptyEntries).ToList()(0).ToString



Hi @Maverick,

Convert the number into string and follow this method.

Substring helpes here…

It will be successful even if you remove comma from the entire number.



Thanks, this is working like i wanted !!


Hi Mahesh,
your solution is more flexible,as it is working with all values. thanks !!
I need to do a summation of this column, containing comma values like… 1,00 2,00 10,00 etc. Comma represents decimal notation so i need to ignore the zeroes and consider only preceeding value. I tried using “Compute(SUM(columnname)” but it won’t work… how can i alter the values in datatable itself and do the summation?



Try this

Declare a variable with type double Sum

Sum=dt.AsEnumerable.Sum(Function(row) Convert.ToDouble(row(“Column_Name”).ToString.Split({","},stringSplitOptions.RemoveEmptyEntries)(0)))



Hi mahesh…

I have a data like this 1,234.00 i need to remove the decimal nd 2 zeroes. Can u help m



Let us take





Hi @Darshhan,

This activity will help you. It has with sample



Hi mahesh…

I scraped a structured data from the web. The problem is that some string in the data contains comma, and when I put the structured data in a csv that’s a problem because I can’t divide it properly with the unwanted comma.

How can I scan over the entire structured data to remove the comma and afterwards write the csv?

Thanks a lot


Hi @Stefano_Skjupyter

You can use a simple .Replace method on a string, like this:


This replaces all commas with nothing, effectively removing all commas.


Thanks @loginerror

the problem is my data type is a data table, not a single variable type string. I think I should iterate over it with a for cycle for example. is that correct?



Indeed, that would be the approach. I am pretty sure someone knows a 1-liner for that in an Assign activity, but they would have to speak up (maybe @ClaytonM, if he feels like it; I don’t like using direct tags like that :slight_smile: )


Hi @Stefano_Skjupyter

From my understanding, you can’t change row items in a datatable without using a For Each to loop through each row.

Also, you don’t necessarily need to remove the comma because if you surround that item with quotes, then the CSV will delimit the value correctly.

So basically if would look like this:

For each activity: For each row in dt1
            If row.Item("columnname").ToString.Contains(",")
                  Assign: row.Item("columnname") = """"+ row.Item("columnname").ToString+""""
                  // or row.Item("columnname") = row.Item("columnname").ToString.Replace(",","")

So that would loop through each row and change the value using an Assign activity.

If the data has thousands of rows, this may not be an efficient solution. The other method would be to manipulate the entire structured data as a string (ie using Output Data Table). However, if you look at the entire row as one string, I don’t know how you would identify which commas are delimiters and which commas need to be removed.

EDIT: added if condition in pseudocode to check if value contains comma



Oh, you can also filter your table prior to replacing the commas, rather than looping through each row.

That would be like this:

For Each (Framework) activity: For each row in dt1.AsEnumerable.Where(Function(r) r("columnname").ToString.Contains(",") ).ToArray
         Assign: row("columnname") = """"+ row.Item("columnname").ToString+""""
                  // or row.Item("columnname") = row.Item("columnname").ToString.Replace(",","")


I am used to programming in python where I can put I piece of code essentially where I want to, but in this platform where should I copy paste your piece of code to be executed??

sorry if the question might sound silly



Sorry let me clarify. My examples were just pseudocode as a representation of the logic.

Here is a more visual representation done in UiPath:

Here are the example For Each activities in a workflow:
foreach.xaml (12.9 KB)