/** * <p> * Case insensitive check if a String starts with a specified prefix. * </p> * <p> * <code>null</code>s are handled without exceptions. Two <code>null</code> references are considered to be equal. The * comparison is case insensitive. * </p> * * <pre> * StringUtils.startsWithIgnoreCase(null, null) = true * StringUtils.startsWithIgnoreCase(null, "abcdef") = false * StringUtils.startsWithIgnoreCase("abc", null) = false * StringUtils.startsWithIgnoreCase("abc", "abcdef") = true * StringUtils.startsWithIgnoreCase("abc", "ABCDEF") = true * </pre> * * @see java.lang.String#startsWith(String) * @param str * the String to check, may be null * @param prefix * the prefix to find, may be null * @return <code>true</code> if the String starts with the prefix, case insensitive, or both <code>null</code> * @since 2.4 */ public static boolean startsWithIgnoreCase(final String str, final String prefix) { return startsWith(str, prefix, true); }
/** * <p> * Case insensitive check if a String starts with a specified prefix. * </p> * <p> * <code>null</code>s are handled without exceptions. Two <code>null</code> references are considered to be equal. The * comparison is case insensitive. * </p> * * <pre> * StringUtils.startsWithIgnoreCase(null, null) = true * StringUtils.startsWithIgnoreCase(null, "abcdef") = false * StringUtils.startsWithIgnoreCase("abc", null) = false * StringUtils.startsWithIgnoreCase("abc", "abcdef") = true * StringUtils.startsWithIgnoreCase("abc", "ABCDEF") = true * </pre> * * @see java.lang.String#startsWith(String) * @param str * the String to check, may be null * @param prefix * the prefix to find, may be null * @return <code>true</code> if the String starts with the prefix, case insensitive, or both <code>null</code> * @since 2.4 */ public static boolean startsWithIgnoreCase(final String str, final String prefix) { return startsWith(str, prefix, true); }