String operations in uipath

Hi, I am new to uipath and I am having this simple query. I need to get text “ANALYTICS_Security.20190503.tar.gz” from text “ANALYTICS_Security.20190503.tar.gz 7728766 bytes”.

In other words, I need to get text from beginning to the first space (" “). Any help on it would be much appreciated. NOTE: The space mentioned above can be single(” “) or multiple spaces(” "). Thanks!

1 Like

Hi @Ramya12

Welcome to UiPath community
Here you go, try like this

in_text = “ANALYTICS_Security.20190503.tar.gz 7728766 bytes”

out_text = split(in_text," ")(0).ToString.Trim (modified @Ramya12)

This worked @Ramya12
Cheers

1 Like

hi palaniyappan,
My input string will vary below are the some sample input strings
SSC2BRS_cpn_in_20190506_XLC.txt 5779 bytes
SSC2BRS_secd_camra_20190506.CSV 252 bytes
BRS2MARKIT_Decode.20190506.XML 5446782 bytes
BRS2MARKIT_IndexWeights.20190503.tar.gz 75060 bytes
we have to retrive the first part in each input string.
Thanks

Fine then you can use this
doesn’t matter the number of space between the first and second, as we are not going to get the word followed by a space, we are going to get only before the space, so this would work for sure in all scenarios

out_text = split(in_text," ")(0).ToString.Trim
This worked again
@Ramya12
Though it has varying number of space between
we are getting the value we need

Cheers @Ramya12

Did that work @Ramya12

No it’s not working it’s not even copying single character also @Palaniyappan

1 Like

Fine will be of single line like this @Ramya12
SSC2BRS_cpn_in_20190506_XLC.txt 5779 bytes

or

multiple lines
SSC2BRS_cpn_in_20190506_XLC.txt 5779 bytes
SSC2BRS_secd_camra_20190506.CSV 252 bytes
BRS2MARKIT_Decode.20190506.XML 5446782 bytes
BRS2MARKIT_IndexWeights.20190503.tar.gz 75060 bytes

Cheers

we have multiple lines in one file @Palaniyappan

1 Like

aaah , thats why
then try like this

intext = " SSC2BRS_cpn_in_20190506_XLC.txt 5779 bytes
SSC2BRS_secd_camra_20190506.CSV 252 bytes
BRS2MARKIT_Decode.20190506.XML 5446782 bytes
BRS2MARKIT_IndexWeights.20190503.tar.gz 75060 bytes "

and

outtext_array = intext.ToString.Split(Environment.Newline.ToArray())

where outtext_array is a variable of type string array, which has the array of lines from the read text file

now use a for each loop with the above variable “outtext_array” as input and change the type argument of for each loop as string
the inside the loop use a write line activity and give input like this

Finaltext = split(outtext_array," ")(0).ToString.Trim

Cheers @Ramya12

Did that work @Ramya12

Hi @Palaniyappan , sorry for bothering you again but I am reading those input texts from email and this is how those texts looks like when seen in output after writing through writeline,

Text1 - \t\tBRS2MARKIT_Decode.20190506.XML\t5446782 bytes\r\n5/6/2019, 10

Text2 - \t\tBRS2MARKIT_IndexWeights.20190503.tar.gz\t75060 bytes\r\n5/6/2019, 7

Text3 - \t\tBRS2MARKIT_IndexWeights.20190707.tar.gz.csv\t75060 bytes\r\n5/6/2019, 7

I have attached the snapshot from output as well where I have highlighted these texts. I want to retrive the highlighted portion of the text. I would be great if you could help me with same. Or you can help me with finding the last position on Dot “.” so that I can do substring on it with length as 3 more than last postion of Dot. For example,

TextToBeRetrieved = InText.Substring(0, LastIndexOfDot + 3).

Thanks!

hmmm i m not able to see any snapshot of the output @Ramya12

I have attached the snapchat

thanks!

Fine
hope this would help you resolve this

–lets take like you have the string stored in a variable named strinput
–then use a Matches activity where in the input mention as strinput and in expression mention as “^.*(?=\s)”
–this will store all the values we need in a variable of type System.Collections.Generic.Ienumerable(System.Text.RegularExpressions.Match) and name it out_matches

–then use a FOR EACH activity and pass the above variable out_matches and change the type argument as System.Text.RegularExpresions.Match and inside that use a writeline activity and mention as item.ToString.Trim

cheers @Ramya12

HI @Palaniyappan, when I click on that text in output, I am, getting \t\t as in attached snapshot.

Hi there @Ramya12

Welcome to Uipath community

I have attached a xaml using your four lines that needed string operation. Open the project and run it i am sure you will have a solution - output panel will show the split string results. Open and run the ‘Main’ file xaml only, refer ‘new text Document’ for your strings.

FILE : StringOperation (526.3 KB)

Regards :slight_smile:

Hi @Ramya12

Attached sample flow please go through it.

  1. input value is stored in variable a = BRS2MARKIT_IndexWeights.20190503.tar.gz 75060 bytes
  2. From input by using string operation i am getting data after Last period(“.”) and storing it in b = “gz 75060 bytes”
  3. Usging Regex extracting only digits. - 75060
  4. Showing result in Message box. - 75060

Regards,
Vijay.

BlankProcess2.zip (13.6 KB)

Hey @Ramya12

did you check my approach ?? is it wokring …??

Regards,
Vijay.

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