3 4 Data Manipulation: Using status.Split({"Record ", " has"})

uiautomation
pdf
datascraping

#1

The above video deals with Data Manipulation and at this part of the video, (9min and 53s) shows how to use status.Split to find and return a word in a string that comes between “Record " and " has” as the delimiters.

I am looking for how to find and return a word that comes after a word, but the word that will follow my target data will vary each time so I can’t use 2 delimiters.

In the string: “Scheduled : 07.15.17” I’m looking to extract the date as I know it will always follow the “Scheduled :” but again, the word that would follow it will vary every time.

status.Split will split the string and I can return a word if I know what it is between, but how do I return a word if I only know what precedes it?

In standard English I’m trying to tell the computer, "Find the phrase “Scheduled :” and return the 8 characters that follow. (the place on the page where Scheduled will appear will vary as well so I can’t use Substring to find the information)

Thanks so much in advance for your help!!


#2
string toBeSearched = "Scheduled : ";
string code = myString.Substring(myString.IndexOf(toBeSearched) + toBeSearched.Length);

or

Use Regex: (?<=Scheduled : ).*

https://regex101.com/r/dmYhAY/1


#3

Thanks so much for your reply.

Where would I put this code in UIPath? I mean where would this code go, into what container? An “If” container? An assign Container? Sorry if that seems a silly question.

Second the code you gave seems to work great if there is nothing after the date I am looking to capture but it is capturing everything after the “Scheduled :”.

I could in theory create that into a String and only return the SubString (0,8) of that string, but that seems like 2 steps to do one thing.

Is there a way using what you showed but have it end the search after 8 characters?

Again thanks so much I really appreciate the help here, I’m just having trouble finding answers for so your help is valued greatly.


#4

You can try below regex for 8 character limit after colon.Pass this in Matches activity.

https://regex101.com/r/dmYhAY/2

Thanks,
Vinay


#5

I can see that using regex is exactly what I need to get a firm hold of and that the Regex you showed me is returning only what I’m looking for even with text in front of it. Thank you, now I’m trying to get it entered into the “Matches” box and I’m getting the following error,

“Compiler error(s) encountered processing expression
Expression expected.”

You can see that the input is what I’m having it read,
The output is a variable that is variable type: |Enumerable when I create the variable within the output field using ctrl K so it should be the right type.

Can you tell why I might be getting this error? Did I put it oin the wrong field?


#6

Regex should go between quotes. If you are expecting only one result : idDate(0).ToString


#7

That worked!!! Thanks so much, I’m just learning that Regex is something I can use to get a lot of mileage out of UIPath, so I really appreciate your help! I’ve got it up and running how I’d like. Thanks so much!!!


#8

@vvaidya there is expression “status.Split(” “c)”
what does this c mean and usage?