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

booleanstartsWithCS(String a, String b)
starts With CS
return a == null || b == null ? false : a.startsWith(b);
booleanstartsWithDigitsFollowedByLetters(String str)
Checks whether a string starts with digits and might contains after the digits only letters
int strLen = str.length();
boolean startsWithDigits = false;
int startForLetters = 0;
for (int i = 0; i < strLen; i++) {
    if (Character.isDigit(str.charAt(i))) {
        startsWithDigits = true;
        continue;
    startForLetters = i;
    break;
boolean followedByLetters = true;
if (startsWithDigits && startForLetters > 0) {
    for (int i = startForLetters; i < strLen; i++) {
        if (!Character.isLetter(str.charAt(i))) {
            followedByLetters = false;
            break;
return startsWithDigits && followedByLetters;
booleanstartsWithHtml(Object object)
starts With Html
if (object instanceof CharSequence) {
    return startsWithHtml((CharSequence) object);
} else if (object != null) {
    return startsWithHtml(object.toString());
return false;
booleanstartsWithIC(String s1, String... strings)
Returns whether s1 starts with any of the given strings, ignoring case.
for (String string : strings)
    if (startsWithIC(s1, string))
        return true;
return false;
booleanstartsWithIgnoreCase(final String base, final String start)
Helper functions to query a strings start portion.
if (base.length() < start.length()) {
    return false;
return base.regionMatches(true, 0, start, 0, start.length());
booleanstartsWithIgnoreCase(final String haystack, final String needle)
Does a string start with a second string ignoring case?
return needle.equalsIgnoreCase(haystack.substring(0, needle.length()));
booleanstartsWithIgnoreCase(final String iFirst, final String iSecond)
starts With Ignore Case
if (iFirst == null)
    throw new IllegalArgumentException("Origin string to compare is null");
if (iSecond == null)
    throw new IllegalArgumentException("String to match is null");
final int iSecondLength = iSecond.length();
if (iSecondLength > iFirst.length())
    return false;
for (int i = 0; i < iSecondLength; ++i) {
...
booleanstartsWithIgnoreCase(final String input, final String prefix)
Checks if a string starts with a given suffix.
if (input == null)
    throw new IllegalArgumentException("Input cannot be null!");
if (prefix == null)
    throw new IllegalArgumentException("Suffix cannot be null!");
return input.startsWith(prefix)
        || input.length() >= prefix.length() && input.toLowerCase().startsWith(prefix.toLowerCase());
booleanstartsWithIgnoreCase(final String source, final String target)
Returns true if given source string start with target string ignore case sensitive; false otherwise.
if (source.startsWith(target)) {
    return true;
if (source.length() < target.length()) {
    return false;
return source.substring(0, target.length()).equalsIgnoreCase(target);
booleanstartsWithIgnoreCase(final String str, final String prefix)
starts With Ignore Case
return startsWith(str, prefix, true);