If text exist, get number next to it

What is the best way to do this:

If a given text exist the robot should store the number next to the text as a variable.


Do you have an example text with the number and is it consistent?

If it’s consistently like “abc 123”, then you can simply use .Split()
If text.Contains(“abc”) Then
Assign num = text.Split(" "c)(1)

If it’s not consistent you might look into using Regex instead to pull the number out.

1 Like


There’re a couple ways to do this.

Here’s some activities that can do what you want:

All of those activities returns a True/False value. So, with a condition Activity (If) you can compare what you want and then can get the text from the next field that you need.

1 Like

Will this work if the screen is a picture?

You can use “Image exists” or “OCR Text Exists” if you’re working with pictures :smiley:

ABC will be consistently, the numbers change.

It will be like this:

Bilag 123456

Could the number be replaced by * or ? ?

Since it’s consistent, you might just use the .Split method to keep it simple.

First you need to store the text with Get Text or OCR Text.

Assign num = text.Split({" "},System.StringSplitOptions.RemoveEmptyEntries)(1)

Maybe something like that. I’m sure there are other good solutions too.

1 Like

Maybe there is something i’m missing, but how to i get that specific text that i want?

I have screen scraped the entire page/picture, but how to tell the robot to get the specific text i’m looking for.

If it’s an image, then you need to get all the text in the image with OCR Text. After that you need to find a keyword and split out to the text you are looking for.

For example if “text” is the text you scraped with OCR Text,
num = text.Split({“keyword”},System.StringSplitOptions.None)(1).Trim.Split(vblf(0))(0)

vblf(0) is newline character

If it’s not an image then you could Get Text of the element instead.

So in short, you need to extract the chunk of text, then find the word you want with .Split and a keyword.


Have you tried via Citrix Recorder -> Screen Scraping -> Scrape Relative?

While it may not exactly solve your question (or maybe it does) it definitely will generate a workflow sample for you from which you can try to adopt it. Knowing how to scrape a region to relative to an image is essential with Citrix-type automation.

Will scrape relative work if you have to scroll down to find the text?

i want to split 123 from 123abc using uipath

@ClaytonM What is the ‘c’ for in the split function? text.Split(" "c)(1)


The ‘c’ indicates that it’s a single character :slight_smile:


1 Like