Find some values in a list of string

Hii Suppose i have a list of string like

abcd is my name
pqrs pap are so good
xyz
jkl

so i need to check if pqrs is present or not in a list and if present the extract the whole word “pqrs pap are so good” as a output

Hi @Doonline ,

Suppose we have the list of strings in a variable, say listOfValues, and we have the value "pqrs", in a string variable say valueToFind.

You could achieve your result by using the Expression below :

listOfValues.Where(Function(x)valueToFind.Equals(x)).FirstOrDefault

Let us know if the above doesn’t work.

Not working. I got null Values

Hi @Doonline

I would solve it through the activity for each.

For each string in stringList
If string.Contain(“yours string to choose”) then
Assign output as string
Otherwise nothing happened

And your output should be the string that you want

First split the string using “\n” and then for each item in the split result check if “pqrs” is available and then you will get the whole string. Please try this

strTerm = pqrs
arrResult = YourList.Where(Function (x) x.Contains(strTerm)).toArray

@Doonline

try this workflow->

Sequence.xaml (12.9 KB)

i hope it will help you.

Hi @Doonline ,

Check the updated Expression below :

listOfValues.Where(Function(x)x.Trim.ToLower.Contains(valueToFind.Trim.ToLower)).FirstOrDefault

Sorry not working because my list is taking the whole string as one

grafik

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