Java Utililty Methods String Match Count

List of utility methods to do String Match Count

Description

The list of methods to do String Match Count are organized into topic(s).

Method

intcountMatches(String string, String other)
Returns how many times string contains other.
if (null == string)
    return 0;
if (null == other)
    return 0;
if (0 >= string.length())
    return 0;
if (0 >= other.length())
    return 0;
...
intcountMatches(String theString, String... sep)
count Matches
return (theString == null) ? 0 : theString.length() - theString.replace(separator(sep), "").length();
intcountMatches(String[] query, String[] entry)
Counts how many Strings in the entry array start with the Strings of the query array.
int matches = 0;
int indexOfLastMatchPlusOne = 0;
for (int i = 0; i < query.length && indexOfLastMatchPlusOne < entry.length; i++) {
    for (int j = indexOfLastMatchPlusOne; j < entry.length; j++) {
        if (startsWithIgnoreCase(entry[j], query[i])) {
            indexOfLastMatchPlusOne = j + 1;
            matches++;
return matches;
intcountMatchingLines(Throwable ex, Throwable cause)
Count the number of lines that match between an exception and some cause.
StackTraceElement[] exElements = ex.getStackTrace();
StackTraceElement[] causeElements = cause.getStackTrace();
int i = 0;
int n = Math.min(exElements.length, causeElements.length);
while (i < n) {
    StackTraceElement exElement = exElements[exElements.length - i - 1];
    StackTraceElement causeElement = causeElements[causeElements.length - i - 1];
    if (!causeElement.equals(exElement))
...