I have two String
s, str1
and str2
. How do I check if str2
is contained within str1
, ignoring case?
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.