Java String Starts Wtih startsWithIC(String s1, String... strings)

Here you can find the source of startsWithIC(String s1, String... strings)

Description

Returns whether s1 starts with any of the given strings, ignoring case.

License

Open Source License

Declaration

public static boolean startsWithIC(String s1, String... strings) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  ww  w .ja  va2 s . c  om
     * Returns whether s1 starts with s2, ignoring case.
     */
    public static boolean startsWithIC(String s1, String s2) {
        return s1 != null && s2 != null && s1.regionMatches(true, 0, s2, 0, s2.length());
    }

    /**
     * Returns whether s1 starts with any of the given strings, ignoring case.
     */
    public static boolean startsWithIC(String s1, String... strings) {
        for (String string : strings)
            if (startsWithIC(s1, string))
                return true;
        return false;
    }

    /**
     * Returns the length of given string (supports null).
     */
    public static int length(CharSequence aString) {
        return aString == null ? 0 : aString.length();
    }
}

Related

  1. startsWithConcatenation(String string, String... prefixes)
  2. startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix)
  3. startsWithCS(String a, String b)
  4. startsWithDigitsFollowedByLetters(String str)
  5. startsWithHtml(Object object)
  6. startsWithIgnoreCase(final String base, final String start)
  7. startsWithIgnoreCase(final String haystack, final String needle)
  8. startsWithIgnoreCase(final String iFirst, final String iSecond)
  9. startsWithIgnoreCase(final String input, final String prefix)