How to check if a String contains any of some strings

c#, contains, string

Solution

If you are looking for single characters, you can use `String.IndexOfAny()`.

If you want arbitrary strings, then I'm not aware of a .NET method to achieve that "directly", although a regular expression would work.

Problem

With a `String` `s`, to determine if it contains "a" or "b" or "c". Something that is better than checking each individually: ``` if (s.contains("a")||s.contains("b")||s.contains("c")) ```

Original source