Java String Starts Wtih startsWithIgnoreCase(final String text, final String prefix)

Here you can find the source of startsWithIgnoreCase(final String text, final String prefix)

Description

Tests if the string starts with the specified prefix.

License

Apache License

Parameter

Parameter Description
text the string to test.
prefix the prefix.

Return

true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise. Note also that true will be returned if the prefix is an empty string or is equal to the text String object as determined by the method. If the text or prefix argument is null false is returned.

Declaration

public static boolean startsWithIgnoreCase(final String text, final String prefix) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from   www.ja v a2 s.c o m*/
     * Tests if the string starts with the specified prefix.
     *
     * @param   text     the string to test.
     * @param   prefix   the prefix.
     * @return  <code>true</code> if the character sequence represented by the
     *          argument is a prefix of the character sequence represented by
     *          this string; <code>false</code> otherwise.      
     *          Note also that <code>true</code> will be returned if the 
     *          prefix is an empty string or is equal to the text 
     *          <code>String</code> object as determined by the 
     *          {@link #equals(Object)} method. If the text or 
     *          prefix argument is null <code>false</code> is returned.
     * @since   JDK1. 0
     */
    public static boolean startsWithIgnoreCase(final String text, final String prefix) {
        if (text == null || prefix == null) {
            return false;
        }
        return text.regionMatches(true, 0, prefix, 0, prefix.length());
    }
}

Related

  1. startsWithIgnoreCase(final String str, final String prefix)
  2. startsWithIgnoreCase(final String string, final String start)
  3. startsWithIgnoreCase(final String stringToCheck, final String prefix)
  4. startsWithIgnoreCase(final String target1, final String target2)
  5. startsWithIgnoreCase(final String text, final String prefix)
  6. startsWithIgnoreCase(final String value, final String possiblePrefix)
  7. startsWithIgnoreCase(String a, String b)
  8. startsWithIgnoreCase(String baseString, String compareString)
  9. startsWithIgnoreCase(String haystack, String needle)