In Java, how do I check if a string contains a substring (ignoring case)?

java, string, substring

Solution

str1.toUpperCase().contains(str2.toUpperCase())

UPD:

Original answer was using `toLowerCase()` method. But as some people correctly noticed, there are some exceptions in Unicode and it's better to use `toUpperCase()`. Because:

There are languages knowing more than one lower case variant for one upper case variant.

Problem

I have two `String`s, `str1` and `str2`. How do I check if `str2` is contained within `str1`, ignoring case?

Original source

Related problems