Java Utililty Methods String Starts Wtih

List of utility methods to do String Starts Wtih

Description

The list of methods to do String Starts Wtih are organized into topic(s).

Method

booleanstartsWithIgnoreCase(String whole, String prefix)
starts With Ignore Case
return whole.length() >= prefix.length() && whole.substring(0, prefix.length()).equalsIgnoreCase(prefix);
booleanstartsWithIgnoreCase(String[] compoundName, String[] prefix)
starts With Ignore Case
int prefixLength = prefix.length;
int nameLength = compoundName.length;
if (prefixLength > nameLength)
    return false;
for (int i = 0; i < prefixLength - 1; i++) {
    if (!compoundName[i].equalsIgnoreCase(prefix[i]))
        return false;
return compoundName[prefixLength - 1].toLowerCase().startsWith(prefix[prefixLength - 1].toLowerCase());
booleanstartsWithIgnoreCaseAndNonAlphaNumeric(String searchIn, String searchFor)
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case,leading whitespace and non-alphanumeric characters.
if (searchIn == null) {
    return searchFor == null;
int beginPos = 0;
int inLength = searchIn.length();
for (; beginPos < inLength; beginPos++) {
    char c = searchIn.charAt(beginPos);
    if (Character.isLetterOrDigit(c)) {
...
booleanstartsWithIgnoreCaseAndWs(String searchIn, String searchFor)
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace
return startsWithIgnoreCaseAndWs(searchIn, searchFor, 0);
booleanstartsWithIgnoreCaseAndWs(String searchIn, String searchFor, int beginPos)
Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace
if (searchIn == null) {
    return searchFor == null;
int inLength = searchIn.length();
for (; beginPos < inLength; beginPos++) {
    if (!Character.isWhitespace(searchIn.charAt(beginPos))) {
        break;
return startsWithIgnoreCase(searchIn, beginPos, searchFor);
booleanstartsWithIgnoreWhitespace(String str, String prefix)
starts With Ignore Whitespace
return str.matches("(\\s|\\t)*" + prefix + ".*");
booleanstartsWithIgnoreWhitespaces(String prefix, String string)
Tests if this string starts with the specified prefix (Ignoring whitespaces)
int index1 = 0;
int index2 = 0;
int length1 = prefix.length();
int length2 = string.length();
char ch1 = ' ';
char ch2 = ' ';
while (index1 < length1 && index2 < length2) {
    while (index1 < length1 && Character.isWhitespace(ch1 = prefix.charAt(index1))) {
...
intstartsWithIndex(String[] prefixes, String fullPath)
starts With Index
if (prefixes != null && fullPath != null) {
    int i = 0;
    for (String string : prefixes) {
        if (fullPath.startsWith(string)) {
            return i;
        i++;
return -1;
intstartsWithLenient(final String s, final String[] matches, final int[] minChars, final boolean acceptTrailing)
Returns if a string shares at least a specified numbers starting characters with a number of matches.
for (int i = 0; i < matches.length; i++) {
    final int minChar = minChars != null ? minChars[i] : -1;
    final int ix = startsWithLenient(s, matches[i], minChar, acceptTrailing);
    if (ix > -1) {
        return ix;
return -1;
...
booleanstartsWithLetter(String str)
starts With Letter
if (str == null || str.isEmpty()) {
    return false;
char firstChar = str.charAt(0);
return firstChar >= 'A' && firstChar <= 'z';