Search part of a string for value in Array

Hi,
I have an array that has a list of strings
e.g. arrValue = {“Approved”, “approved”, “Activate”, “activate”, “Yes”, “yes”, “Accept”, “accept”} etc.

I want to search inside of an email in the body if any of these words exist.

I have a variable mailbody = mail.body
which stores the entire mail body inside that variable

then my if statement is
IF: arrValue.Contains(mailbody)

The issue I have is that if it takes the whole body in and cant match the word even though the word “approved” is in the email. this method worksfine if my ‘mailbody’ = “approved” but when the the body has other things in it like “Approved by John Smith” this returns the statement above as false.

Thanks in advanced for any help.

  1. During comparison, please convert the mail body to Upper/Lower Case based on your preference : mailBody.ToUpper.Contains(arrValue).
  2. You can keep only upper/lower case items in the array and this way your comparison will always work. Your array should be like : {“APPROVED”,“YES”,“NO”}
    Try this and let me know.
2 Likes

Try this
arrValue.Any(function(x) mailbody.Split(" ".ToArray,StringSplitOptions.RemoveEmptyEntries).Contains(x)).ToString