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

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)