Java – case insensitive string What is an alternative to the contains method?
See English answers > how to check if a string contains another string in a case insensitive manner in Java? 17
If there is "someexamplestring" in the line, it will not be returned
How do I recognize strings in a case insensitive manner?
Solution
In fact, how to check if a string contains another string in a case insensitive manner in Java? Copy of
If you have simpler requirements and only deal with English letters, you can follow the answers below
You should do string toLowerCase(). contains(“someExampleString”.toLowerCase());.
Learn more about public string tolower case() from Java se documentation
In addition, as implied by Artur biesiadowski in the comment section of the question, repeat the iteration here:
In addition, to make it more secure, you can use another method, tolower case (locale. English), and always cover the locale to English However, the limitation is that you are no longer international
string.toLowerCase(Locale.English).contains("someExampleString".toLowerCase(Locale.English));