Java String Starts Wtih startsWithIgnoreCase(String p_sStr, String p_sSubStr)

Here you can find the source of startsWithIgnoreCase(String p_sStr, String p_sSubStr)

Description

Same as String#startsWith(String) , but ignoring case

License

Apache License

Parameter

Parameter Description
p_sStr string value
p_sSubStr sub string

Return

true, if substring

Declaration

public static boolean startsWithIgnoreCase(String p_sStr, String p_sSubStr) 

Method Source Code

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

public class Main {
    /**//from w  w  w .j  a  va 2 s  . c o m
     * Same as {@link String#startsWith(String)}, but ignoring case
     * 
     * @param p_sStr string value
     * @param p_sSubStr sub string
     * @return true, if substring
     */
    public static boolean startsWithIgnoreCase(String p_sStr, String p_sSubStr) {
        if (p_sSubStr.length() > p_sStr.length())
            return false;
        for (int i = 0; i < p_sSubStr.length(); i++) {
            char cSubStr = p_sSubStr.charAt(i);
            char cStr = p_sStr.charAt(i);
            char cSubStrLC = Character.toLowerCase(cSubStr);
            char cStrLC = Character.toLowerCase(cStr);

            if (cSubStrLC != cStrLC)
                return false;
        }
        return true;
    }
}

Related

  1. startsWithIgnoreCase(String input, String prefix)
  2. startsWithIgnoreCase(String inputValue, String prefix)
  3. startsWithIgnoreCase(String main, String with)
  4. startsWithIgnoreCase(String name, Iterable patterns)
  5. startsWithIgnoreCase(String originalString, String checkPhrase)
  6. startsWithIgnoreCase(String s, int offset, int end, String lowerCase)
  7. startsWithIgnoreCase(String s, String prefix)
  8. startsWithIgnoreCase(String s, String prefix)
  9. startsWithIgnoreCase(String s, String prefix)