Check string in a List<of Strings>

Hi folks,

I am trying to find a string (from a list of strings), if that contains in a string (email body). I feel something is amiss. Couldn’t find what or if the approach is right! Also how would i include ignore case while checking?

My use case: Need to check if any of the strings below is contained in the email

List of strings to check:

{“Unable to upload”,“Upload files failed”,“Upload failed”,“Failed to upload”,
“Missing route document”,“Files not received”,“Files not found”,“File transfer failed”,
“File transfer not received”,“Permit not routed”,“Permit is in unreadable format”,“Did not receive permit”,“Received permit from another company”,“Web defacement”})

Email body:

Dear Tom,

Subject: File transfer failed

A ticket has been logged for this request. Please retain this ticket number for reference purposes."

thanks,
Joshi

Hi @Joshikumarav ,

You can use
list.contains("your value")

Regards, Arivu

3 Likes

Actually, that wouldn’t’ help much, would it? Because i need to check every element of the list with my email body. Can i do it wihout a for loop?

@Joshikumarav

keywords.Any(function(s) email.Contains(s))

This will check all the list items in the email for existance

Hi,

You can try like this,

strList.Contains(chkString, StringComparer.OrdinalIgnoreCase)

Perfect. this works. but how do i ignore the word case? check irrespective of uppercase or lower case.

Thanks
Joshi

try keywords.Any(function(s) email.toLower.Contains(s.toLower))

i think that wouldn’t work. Because what I want is to ignore them as my input may come in any case.

This will convert both your email and the string in list to lowercase. Hence this will work

2 Likes

Perfect. Worked like a charm.