String Manipulations to get the particular line from the datatable's cell

Hi team,
Experts:- @supermanPunch , @ppr Plz help

I am having as data as shown below:

I am able to get it into the Datatable and trying to use the string manipulation on the cell (cell has all the data from “0 - Pickup … Main data”) AND WHAT I want is to fetch text “Main data” into a string variable.

But issue is that onces I am printing value in the message box, I am getting the string in following manner:

I tried splitting string with respect to " ", “\n” , “\t” etc

But the bot is assuming a string to be as shown below:

image

which is making it impossible to extract the Main data into the string variable.

[Note: number of words in all the lines are dynamic]

Kindly suggest,.

Thanks and regards,
@hacky

Give a try with a regex split

arrSplit | String Array =
System.Text.RegularExpressions.Regex.Split(YourStringVar,“\r?\n?”)

Hello @hacky

Can you please share a sample excel with the input data? This will help to apply the required expression.

Thanks

@Rahul_Unnikrishnan

Apologies, the data is confidential, cannot share it online. I tried to make a dummy data to mimic the real time data in this case.

@hacky

Plz refer to the below similar post as well.

Thanks

Not working.

@hacky ,

Alternate Check on the below Expression :

System.Text.RegularExpressions.Regex.Split(YourStringVar,"\s{2,}")

better to tell us the details.

Lets do one thing:

  • Set Breakpoint
  • debug and get paused
  • use the immediate panel and type in the variable with the cell tect value string OR the retrieval to the particular cell value

Just share it with us. Thanks

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Unrecognized escape sequence

@ppr Actually I am not using UiPath, I am using another tool based on dotnet framework itself. And since logic remains same, I am asking it here.

@hacky ,

May we ask you which tool is being used ? Also How is the suggested Expression used in that tool ? Is there an intelli sense available in it ?

@supermanPunch

System.Text.RegularExpressions.Regex.Split(dt_RawDatatable_RouteInformation.Rows[1][“Column1”].ToString(), @“\s{3,}”).Count()

This works.

1 Like

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