How to extract a value from a string?

I need to extract 34 from the string “1 to 34 out of 34 candidates”.
I am using "(?<=1 to) [\s\S]+?(?= out) " to extract 34 and I use “Matches” activity in UiPath to execute the same.

What I am getting is :slight_smile:
System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]

image

Hi @sivapriya.s,

Can you try this
Regex.Match("1 to 34 out of 34 candidates","(?<=1 to) [\s\S]+?(?= out)").Value

(?<=1 to\s)[\s\S]+?(?= out)

Hi @sivapriya.s
try this

\d{2}

Thanks
Ashwin S

Hi
we can use a simple assign activity like this
stroutput = System.Text.RegularExpressions.Regex.Match(TotalResults.ToString,“(?<=to).*(?=out)”).ToString.Trim

Cheers @sivapriya.s

I tried all the above expressions. But getting the same error.

I am able to get value in Regex editor.
But while executing in UiPath, I am getting the error.

I am using Match Activity here.
Is there any other Activity?

did this expression helped you on this
may i know the error if any on this or the output we get
@sivapriya.s

@sivapriya.s

Use assign activity
var1 = Regex.Match("1 to 34 out of 34 candidates","(?<=1 to) [\s\S]+?(?= out)").Value

@aanandsanraj

Thank you so much. It worked. :slight_smile:

You are Welcome @sivapriya.s :slightly_smiling_face: