String Manipulation for apostrophes

I have scratched my head for too long but I couldn’t come with a feasible solution

Can somebody help me with this ?

There are 2 things which I need to perform in this

  1. Detect any number with double quotes and remove the comma inside of the number and then remove the double quotes

  2. Delete additional Zeroes after decimal points and eliminate the decimal if its (.00) and make it a normal number

1 Like

Hi @Ishan_Shelke

You can try with Regex expression

System.Text.RegularExpressions.Regex.Replace(YourString,""|.00","").Tostring

Regards
Gokul

Hi @Ishan_Shelke
Try this regex pattern “|.00” in regex builder action in UiPath

Sample Output:
image

Thanks!!!

Hi @Gokul001, @jack.chan

Tried your expression but this is not replacing the comma inside the apostrophe numbers

See Image below for reference

Try with the below string :

3823351,AL GHURAIR FOODS LLC PO BOX 780 DUBAI,“99,060.00”,“33,020.00”,74.5564000,73.5700000,“3,386.67”,“9,818,225.05”

and try to make it like this :

3823351,AL GHURAIR FOODS LLC PO BOX 780 DUBAI,99060.00,33020.00,74.5564000,73.5700000,3386.67,9818225.05

Hi @Ishan_Shelke

Try this expression first with your expression

System.Text.RegularExpressions.Regex.Replace(YourString,"(?<=\d)\,(?=\d+)").Tostring

The above will remove the comma, then you use this expression with the input string of above expressions output

System.Text.RegularExpressions.Regex.Replace(YourString,""|.00","").Tostring


Regards
Sudharsan

HI,

Another approach:

How about the following?

First convert input string to datatable because it seems csv data.

Next, convert it to expected format using the following expression.

dt = {dt.CLone.LoadDataRow(Enumerable.Range(0,dt.Columns.Count).Select(Function(i) if(Double.TryParse(dt.Rows(0)(i).ToString,System.Globalization.NumberStyles.Any,System.Globalization.CultureInfo.InvariantCulture,new Double),Double.Parse(dt.Rows(0)(i).ToString,System.Globalization.NumberStyles.Any).ToString,dt.Rows(0)(i).ToString)).ToArray,False)}.CopyToDataTable

Then use OutputDataTable activity.

Sample20220104-6L.zip (2.6 KB)

Regards,

1 Like

@Ishan_Shelke

Above Output as input to second expression

Regards
Sudharsan

@Ishan_Shelke

Make sure to the double quotes you are using it must be “” and not

@Ishan_Shelke,

If you are getting it as output then you can try something like this:

"3823351,AL GHURAIR FOODS LLC PO BOX 780 DUBAI,""99,060.00"",""33,020.00"",74.5564000,73.5700000,""3,386.67"",""9,818,225.05""".Replace("""", "")

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