Check for multiple words in an email body/subject

activities

#1

I would like to check for the occurrence of a collection of words in email body/subject or a word document.

I am able to use .Contains, but it only accepts only one parameter. how can use something like this:

s.Contains(“a”, “b”, “c”);

Thanks,
Joshi


#2

Hi,

You can use this syntax: s.Contains(“a”) and s.Contains(“b”) and s.Contains(“c”).

Thanks,
Ninett


#3

The problem is I have a long list. Some 40 words. Is there any other effecient way to do this?


#4

Hi @Joshikumarav,

you can create one array string[]
arrValue={“a”,“b”,“c”,“d”}

arrValue.Contains(YourString).Tostring()
True/1->value present in the given string
False/0->value not present in the given string

Regards,
Arivu :slight_smile:


#5

@Joshikumarav

Split the string based on Space and store it in a List of strings. let us take List A

and Define List B with words which you want to compare.

now take int c=ListA.Intersect(ListB).Count

If int c equal to List B.Count then all the words of list B will be there in string. If int c is zero then string won’t contain any of the words of list B

Regards,
Mahesh