Data Manipulation in Studio: String Manipulation

Hi all! I am very new to RPA development. I’m trying to understand string manipulation. Can someone explain this fully:

InitialMessage.Split("."c).First.ToString.Substring(InitialMessage.LastIndexOf(“author”)+“author”.Length).Trim

To provide some context, here are all the values:

InitialMessage Variable Value: “You searched for author William Shakespeare. His books can be found in the following stores: Bookland, The Bookshop, Downtown Books, Classics Bookstore.”

Author Variable Value: InitialMessage.Split("."c).First.ToString.Substring(InitialMessage.LastIndexOf(“author”)+“author”.Length).Trim

Bookstore Variable Value:
InitialMessage.Split(".“c)(1).ToString.Split(”:“c).Last.ToString.Split(”,"c).ToList

OutputString Variable Value: String.Format(“Availability for {0}: {1}”,Author,String.Join(","c+vbcr,Bookstores))

that syntax means, the text will be first splitted into array of string with “.” as a separator.
After this that one string will be splitted into 2 sections

then .First means the first array element will be picked
You searched for author William Shakespeare.

then Substring will take a part of the above generated string
That will be Last index of author → that means the position of a (of author) in that sentence, that is 17 + the length of author word that is 6 → 17 + 6 = 23
Now that substring will take the above generated text and then fetch the part of that which s after 23 character position, that will give you “William Shakespeare”

you can check the below post to be aware and learn the basics

How to manipulate a part of string: Split, Trim, Substring, Replace, Remove, Left, Right - News / Tutorials - UiPath Community Forum

1 Like

Thank you Rahul!

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