Java String Starts Wtih startsWithIgnoreCase(String s, String prefix)

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

Description

starts With Ignore Case

License

Apache License

Declaration

public static boolean startsWithIgnoreCase(String s, String prefix) 

Method Source Code

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

public class Main {
    public static boolean startsWithIgnoreCase(String s, String prefix) {

        int length = prefix.length();

        if (s.length() < length)
            return false;

        for (int i = 0; i < length; i++) {
            char c1 = s.charAt(i);
            char c2 = prefix.charAt(i);

            if (c1 == c2)
                continue;

            if (Character.toUpperCase(c1) != Character.toUpperCase(c2)
                    && Character.toLowerCase(c1) != Character.toLowerCase(c2))
                return false;
        }// w  w w. jav a  2  s  .  c o m
        return true;
    }
}

Related

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