Here you can find the source of containsIgnoreCase(String str, String query)
Parameter | Description |
---|---|
str | a parameter |
query | a parameter |
public static boolean containsIgnoreCase(String str, String query)
//package com.java2s; public class Main { /**//from w w w. j a v a 2 s . c om * 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; } private static boolean matchesIgnoreCase(String str, String query, int startingAt) { int len = query.length(); for (int i = 0; i < len; i++) { if (Character.toUpperCase(query.charAt(i)) != Character .toUpperCase(str.charAt(startingAt + i))) { return false; } } return true; } }