How to check if a String contains another String in a case insensitive manner in Java?
Answers
Answered by
0
String s1 = "AbBaCca";
String s2 = "bac";
I want to perform a check returning that s2 is contained within s1. I can do this with:
return s1.contains(s2);
I am pretty sure that contains() is case sensitive, however I can't determine this for sure from reading the documentation. If it is then I suppose my best method would be something like:
return s1.toLowerCase().contains(s2.toLowerCase());
All this aside, is there another (possibly better) way to accomplish this without caring about case-sensitivity?
please make me brainlist
Similar questions