How to use regular expressions in UiPath

Hi everybody,

I’m scraping information from an application and I have each time a string like “You have (400.65 points)”, but it can be also 34.90 or 4059.56, so I tried to scrap each time the number with a regular expression:

Regex.Match(OCRStringOutput, @"^0-9?$").Value

But this expression don’t work. Have you an idea to extract each time only the number from the string?


Try this (probably could be made better, I’m not a big fan of regex):

Regex.Match(sampleString, “([0-9]).+([0-9])”).Value

Your original expression would translate to something that doesn’t match your input:
From beginning of string match character 0 then - then one-or-more 9 then end of string.

Also the @ sign is not needed, that’s from C# to mark a string literal (to not need to escape special chars).


Hello nSangui, I guess we need more information. Please let me know why are you scrapping:

is it because it’s a citrix enviroment?

have you tried to use find relative image option when there is no selector available?

you can click on find image find the relative element of the value you are trying to get, for example “score” and then use relative reference to scrap the value.


Hi @andrzej.kniola, I use regex extensively for extracting data from non structured files, and to be honest it’s the only method I know. You said you are not a big fan of regex. I am curious what method do you use to extract data from non structured files, emails, etc ?


Hi everybody, thanks for your answers!!

The environment where I’m working is a java application, and the complete sentence is “Career HSSE : (2345.65 point(s) HSSE)”, but UiPath identifies the section where the sentence is as an image.

I scrap because I want to extract this number to compare with another scraped from another application.

I extracted all the sentence and I’m trying to use the Regex to extract this double that changes every time (I need to compare some numbers), but I’ll also try the find relative one more time (I’ve tried, but didn’t work I think)


I have a followup-question: How do I use this type of expression in UiPath? (e.g. Regex.Match(somestring, @"\d+").Value)
I have tried to use this directly in an Assign activity, but I am not able to run it:

“Compiler error(s) encountered processing expression “Regex.Match(somestring, @”\d+”).Value". Expression expected."

Should I have used the “Invoke method” instead? If so, can someone point to a user guide for how to use this please?

You can use the Matches activity.



you can try this flow,gmail from string.xaml (10.2 KB)

1 Like

If anyone is still looking for a solution, just use the activity “Matches” in UiPath, just as @andraciorici suggested.
As for the regex to be used for the above problem, use the following: “\b\d+.\d{2}\b”

Can someone help me write regex from the attached screenshot? I need only the value(i.e after colon

) of Metric name, Service name and Time

Please check the output Pane.

Hi @Neha2111,

Refer this post.


Hi, Can you help me with this -

From the screenshot, I want only ECS Cpu Utilization , the given service name (i.e after colon and just before clusterName) and time.


Hi @Neha2111,

Get Metric value:
Use Matches activity
Input : strvalue
Pattern : ((?<=Metric name:).*(?=ServiceName::))
Result: iEnumResult ->IEnumberable
after that use assign activity to get the data
strMetric =iEnumResult (0).ToString()


when I use Regex it is coming as not declared should I download any specific library to use that

@harinathreddy.yn,Go to imports and import namespace system.text.regularexpressions

I tried that, but I am unable to find it.



@arivu96 hi . i wanted to ask you if i want to get all the matches and store them in an array of strings , how would i do that? For example: arrStrmetric = ? ;

Hi @Alex_Risteiu,

Refer the above example

So iEnumResult is IEnumerable dataType.

you can use the Foreach activity to loop through the data.