Here you can find the source of startsWithIgnoreCase(String str, String start)
str
starts with start
, ignoring case.
Parameter | Description |
---|---|
str | The string to check. |
start | The prefix to check for. |
str
starts with start
, ignoring case.
public static boolean startsWithIgnoreCase(String str, String start)
//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; } }