@Test public void testIndexOfIgnoreCase() { String text = "test"; assertEquals(-1,StringUtil.indexOfIgnoreCase(null,text)); assertEquals(-1,StringUtil.indexOfIgnoreCase("",text)); assertEquals(-1,StringUtil.indexOfIgnoreCase(text,null)); assertEquals(-1,StringUtil.indexOfIgnoreCase(text,"")); assertEquals(-1,StringUtil.indexOfIgnoreCase(text,"testing")); assertEquals(1,StringUtil.indexOfIgnoreCase(text,"es")); assertEquals(1,StringUtil.indexOfIgnoreCase(text,"Es")); assertEquals(1,StringUtil.indexOfIgnoreCase(text,"eS")); assertEquals(2,StringUtil.indexOfIgnoreCase(text,"ST")); }
public static int indexOfIgnoreCase(final String text, final String str) { if (isEmpty(text)) { return -1; } if (isEmpty(str)) { return -1; } int len = text.length() - str.length(); for (int i = 0; i <= len; i++) { if (text.regionMatches(true, i, str, 0, str.length())) { return i; } } return -1; }
StringUtil { public static int indexOfIgnoreCase(final String text, final String str) { if (isEmpty(text)) { return -1; } if (isEmpty(str)) { return -1; } int len = text.length() - str.length(); for (int i = 0; i <= len; i++) { if (text.regionMatches(true, i, str, 0, str.length())) { return i; } } return -1; } }
StringUtil { public static int indexOfIgnoreCase(final String text, final String str) { if (isEmpty(text)) { return -1; } if (isEmpty(str)) { return -1; } int len = text.length() - str.length(); for (int i = 0; i <= len; i++) { if (text.regionMatches(true, i, str, 0, str.length())) { return i; } } return -1; } private  StringUtil(); }
StringUtil { public static int indexOfIgnoreCase(final String text, final String str) { if (isEmpty(text)) { return -1; } if (isEmpty(str)) { return -1; } int len = text.length() - str.length(); for (int i = 0; i <= len; i++) { if (text.regionMatches(true, i, str, 0, str.length())) { return i; } } return -1; } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb); }
StringUtil { public static int indexOfIgnoreCase(final String text, final String str) { if (isEmpty(text)) { return -1; } if (isEmpty(str)) { return -1; } int len = text.length() - str.length(); for (int i = 0; i <= len; i++) { if (text.regionMatches(true, i, str, 0, str.length())) { return i; } } return -1; } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb);  }