Java Collection Contain containsAnyIgnoreCase(String string, Collection searchStrings)

Here you can find the source of containsAnyIgnoreCase(String string, Collection searchStrings)

Description

Indicates whether the given string contains any of the given search strings.

License

Open Source License

Parameter

Parameter Description
string the string to check, can be null.
searchStrings the strings to check against.

Return

true or false.

Declaration

public static boolean containsAnyIgnoreCase(String string,
        Collection<String> searchStrings) 

Method Source Code

//package com.java2s;

import java.util.Collection;

public class Main {
    /**//from  ww  w.  j  a  v  a2  s . c o  m
     * Indicates whether the given string contains any of the given search
     * strings. The operation ignores case and leading and trailing blanks.
     * 
     * @param string the string to check, can be null.
     * @param searchStrings the strings to check against.
     * @return true or false.
     */
    public static boolean containsAnyIgnoreCase(String string,
            Collection<String> searchStrings) {
        if (string == null || searchStrings == null) {
            return false;
        }

        for (String searchString : searchStrings) {
            if (string.trim().toLowerCase()
                    .contains(searchString.trim().toLowerCase())) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. containsAny(final Collection a, final Collection b)
  2. containsAny(final Collection coll1, final Collection coll2)
  3. containsAny(final Collection collection, final Object... items)
  4. containsAny(final Collection collection1, final Collection collection2)
  5. containsAny(final Collection a, final Collection b)
  6. containsAnyNull(Collection source)
  7. containsAnyOf(String s, Collection values)
  8. containsAnyVariables(Collection propertyValues)
  9. containsAssignableClass( Collection> clses, Class clazz)