same as String.contains, but ignores case. - Android java.lang

Android examples for java.lang:String Contains

Description

same as String.contains, but ignores case.

Demo Code

import android.text.TextUtils;
import java.util.ArrayList;
import java.util.List;

public class Main{

    /**/*w w  w  .j a  v a  2  s . c  o  m*/
     * same as String.contains, but ignores case.
     * @param str
     * @param query
     * @return
     */
    public static boolean containsIgnoreCase(String str, String query) {
        if (str != null && query != null) {
            int limit = str.length() - query.length() + 1;
            for (int i = 0; i < limit; i++) {
                if (matchesIgnoreCase(str, query, i)) {
                    return true;
                }
            }
        }
        return false;
    }

}

Related Tutorials