Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Option to ignore case with .contains method?

Is there an option to ignore case with .contains() method?

I have an ArrayList of DVD object. Each DVD object has a few elements, one of them is a title. And I have a method that searches for a specific title. It works, but I'd like it to be case insensitive.

like image 303
trama Avatar asked Apr 05 '13 02:04

trama


People also ask

How do I make .contains not case-sensitive?

To perform case insensitive contains in C#, use the String. IndexOf method. The String. IndexOf() finds the first occurrence of a particular string inside another string.

Are .contains case-sensitive?

Returns a Boolean value indicating whether the string contains a given string by performing a case-sensitive, locale-unaware search.

How do you ignore a character in a Java case?

Java String: equalsIgnoreCase() Method The equalsIgnoreCase() Method is used to compare a specified String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

How do you make a case insensitive in C#?

C# String Equals Ignore Case Generally, in c# the string Equals() method will perform case-sensitive string comparison. If we want to perform case insensitive string comparison, we need to use the OrdinalIgnoreCase property and the Equals method.


1 Answers

If you're using Java 8

List<String> list = new ArrayList<>();  boolean containsSearchStr = list.stream().anyMatch("search_value"::equalsIgnoreCase); 
like image 64
Nivas Mane-Patil Avatar answered Sep 19 '22 07:09

Nivas Mane-Patil