How can i get this?

I have a string1=“Apple_Fruit,Grapes,Banana” and string2=“Apple” I want to check if exact string2 is contains in string1…Output=False

Hi @aparna30

String1.contains(string2) if it return true then string 2 is present in string1

Apple is their in Apple_Fruit so its not working

Hello @aparna30
Try this
Use Split Condition for each activity.
Strings.Split(String1,",")
For each loop use condition
Item=string2


It is working for me

It should give false as output because Apple is not equal to Apple_Fruit right???

You are right but again I want to skip this checking for 1 st value Because in this string1 and string 2 first value will be same right? I just want to skip this checking for the first item in string1

@aparna30
Trty this

Strings.Split(String1,",")(1).tostring=string2

**Define**

Grapes=Apple   ---> Output =>False


Strings.Split(String1,",")(2).tostring=string2

Banana= Apple  ---> Output=> False

Refer to this XAML file, you may get some idea
Split.xaml (11.0 KB)

Hello @aparna30

You can do as below.

String1.Contains(String2).ToString

image

Thanks

@aparna30

string1. Split(“,”)(0).equal(string2)
Try this

@aparna30 , Also try this Regex Is Match

System.Text.RegularExpressions.Regex.IsMatch(string1,string2+"$|"+string2+",")

image

1 Like

Hi @aparna30
I will gave simple solution for this.
The first one make as list. The list contains list= new List(of string)(new string(){“Apple_Fruit”,“Grapes”,"Banana”})
The second value make it as string datatype. it contains str = “Apple”.
You need use this function list.contains(str)
The result is false

Please refer the below image
image

Hope you got the answer

5 Likes