Java String Starts Wtih startsWithIgnoreCase(String a, String b)

Here you can find the source of startsWithIgnoreCase(String a, String b)

Description

Returns true if a starts with b regardless of the case.

License

Open Source License

Parameter

Parameter Description
a string to test.
b prefix to test for.

Return

true if a starts with b regardless of the case, false otherwise..

Declaration

public static boolean startsWithIgnoreCase(String a, String b) 

Method Source Code

//package com.java2s;
/*//from   ww  w .  j a  va 2  s .  co m
 * This file is part of muCommander, http://www.mucommander.com
 * Copyright (C) 2002-2010 Maxence Bernard
 *
 * muCommander is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * muCommander is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Returns <code>true</code> if <code>a</code> starts with <code>b</code> regardless of the case.
     * <p>
     * Note that this method will return <code>true</code> if <code>b</code> is an emptry string.
     * </p>
     * @param a string to test.
     * @param b prefix to test for.
     * @return <code>true</code> if <code>a</code> starts with <code>b</code> regardless of the case, <code>false</code> otherwise..
     */
    public static boolean startsWithIgnoreCase(String a, String b) {
        return a.regionMatches(true, 0, b, 0, b.length());
    }
}

Related

  1. startsWithIgnoreCase(final String stringToCheck, final String prefix)
  2. startsWithIgnoreCase(final String target1, final String target2)
  3. startsWithIgnoreCase(final String text, final String prefix)
  4. startsWithIgnoreCase(final String text, final String prefix)
  5. startsWithIgnoreCase(final String value, final String possiblePrefix)
  6. startsWithIgnoreCase(String baseString, String compareString)
  7. startsWithIgnoreCase(String haystack, String needle)
  8. startsWithIgnoreCase(String haystack, String pattern)
  9. startsWithIgnoreCase(String input, String prefix)