Java String Starts Wtih startsWithIgnoreCase(String haystack, String needle)

Here you can find the source of startsWithIgnoreCase(String haystack, String needle)

Description

starts With Ignore Case

License

Open Source License

Parameter

Parameter Description
haystack - string to search
needle - string to look for - must be in lowercase

Declaration

public static boolean startsWithIgnoreCase(String haystack, String needle) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*  w  w  w  . j  a va2  s  .co  m*/
     *
     * @param haystack - string to search
     * @param needle - string to look for - must be in lowercase
     * @return
     */
    public static boolean startsWithIgnoreCase(String haystack, String needle) {
        if (haystack.length() < needle.length()) {
            return false;
        }
        for (int i = 0; i < needle.length(); i++) {
            if (Character.toLowerCase(haystack.charAt(i)) != needle.charAt(i)) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. startsWithIgnoreCase(final String text, final String prefix)
  2. startsWithIgnoreCase(final String text, final String prefix)
  3. startsWithIgnoreCase(final String value, final String possiblePrefix)
  4. startsWithIgnoreCase(String a, String b)
  5. startsWithIgnoreCase(String baseString, String compareString)
  6. startsWithIgnoreCase(String haystack, String pattern)
  7. startsWithIgnoreCase(String input, String prefix)
  8. startsWithIgnoreCase(String inputValue, String prefix)
  9. startsWithIgnoreCase(String main, String with)