ContainsAny in uipath

Hi,do we have ContainsAny function in uipath along with contains

1 Like

@suva Can you explain a bit on what use case you want to use ContainsAny?

ContainsAny is not available as it is specific for collectionutils. But I’m not sure about it @SuvarnaReddy123

I hope we don’t have any method like that may be like this
Yourvariable.Any(Function (a) a.ToString.Contains(“your keyword”)).ToString

Cheers @SuvarnaReddy123


I have one string and i split that string and now i need to check if this strings contains or matches with my input data .

@SuvarnaReddy123 Contains can be used with Array Variable also. To my understanding, you are splitting a string which will then give you an array of elements and now you want to check whether your input data matches with any of the element of the array. So this can be done by using arrayVar.Contains(“your input value”) . It will give you Boolean value either True or False.

Thank you ,it worked fine for my scenario

Yourvariable.Any(Function (a) a.ToString.Contains(“your keyword”)).ToString**
Can you tell me what is the use of Function(a) a in this expression

Function (a) is a accumulator function which is used to select the result value, based on the condition we specify here and here we have contains method.
So Function (a) will retrieve only the one that matches the condition specified
hope this would help you
Cheers @SuvarnaReddy123


I think you accidentally marked your own post as solution.

1 Like

Thanks Palaniyappan,
Still not working for me.

I have one array like strArray1 = {“Apple,grapes,Mango”}
i have another string strSubject = "Apple sent a message to you "

now i need to check if strSubject contains any one of the array items in strArray1 , i am confused how to use Any function here. Can you guide

1 Like

lets make it simple use this expression in a if condition like this
strArray1.Any(Function (a) strSubject.Contains(a))

This will give as TRUE or FALSE based on if the string has any element from array

hope this would help you
Cheers @SuvarnaReddy123

You can use Exist In Collection activity in for each, and it’ll give you the boolean value.

did that work
kindly let know for any queries or clarification
Cheers @SuvarnaReddy123

Thank you @Palaniyappan
I need to check if the strsubject has any keywords which are in the array.
can i use the function like this
strSubject.Any(Function (a) strArray1.Contains(a))
can you guide me

1 Like

Actually this would work buddy
strArray1.Any(Function (a) strSubject.Contains(a))

To check whether strsubject has any keywords which are in the array.

Cheers @SuvarnaReddy123

Thank you @Palaniyappan ,it is giving the correct result

1 Like

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