Java String Starts Wtih startsWithIgnoreCase(String str, String start)

Here you can find the source of startsWithIgnoreCase(String str, String start)

Description

Returns whether str starts with start, ignoring case.

License

BSD License

Parameter

Parameter Description
str The string to check.
start The prefix to check for.

Return

Whether str starts with start, ignoring case.

Declaration

public static boolean startsWithIgnoreCase(String str, String start) 

Method Source Code

//package com.java2s;
/*/*  ww  w .j  a va 2 s  .  co  m*/
 * 12/21/2008
 *
 * Util.java - Utility methods for the autocompletion package.
 * 
 * This library is distributed under a modified BSD license.  See the included
 * RSyntaxTextArea.License.txt file for details.
 */

public class Main {
    /**
     * Returns whether <code>str</code> starts with <code>start</code>,
     * ignoring case.
     *
     * @param str The string to check.
     * @param start The prefix to check for.
     * @return Whether <code>str</code> starts with <code>start</code>,
     *         ignoring case.
     */
    public static boolean startsWithIgnoreCase(String str, String start) {
        int startLen = start.length();
        if (str.length() >= startLen) {
            for (int i = 0; i < startLen; i++) {
                char c1 = str.charAt(i);
                char c2 = start.charAt(i);
                if (Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }
}

Related

  1. startsWithIgnoreCase(String str, String prefix)
  2. startsWithIgnoreCase(String str, String prefix)
  3. startsWithIgnoreCase(String str, String prefix)
  4. startsWithIgnoreCase(String str, String prefix)
  5. startsWithIgnoreCase(String str, String prefix)
  6. startsWithIgnoreCase(String str1, String str2)
  7. startsWithIgnoreCase(String string1, String string2)
  8. startsWithIgnoreCase(String text, String prefix)
  9. startsWithIgnoreCase(String text, String value)