/** *Returnsnumberofnon-interleavedoccurencesofgroupswhichmatchthepattern.
*/ publicint find (String regExpPattern) { if (regExpPattern.length() == 0) { thrownew Failure("Empty string as input parameter for Grep.find(regExpPattern) method");
}
Pattern pattern = Pattern.compile(regExpPattern); int counter = 0; for (int i = 0; i < stringArray.length; i++) {
String string = stringArray[i]; if (string != null) { // Create matcher for this string
Matcher matcher = pattern.matcher(string);
// Find all non-interleaved occurences of pattern in this string for (int ind = 0; ind < string.length(); ) { if (matcher.find(ind)) {
counter++;
ind = matcher.end();
} else { break;
}
}
}
} return counter;
}
/** *ReturnsfirststringofstringArraywithgroupwhichmatches *thepatternoremptystringothrewise.
*/ public String findFirst (String regExpPattern) { if (regExpPattern.length() == 0) { thrownew Failure("Empty string as input parameter for Grep.findFirst(regExpPattern) method");
}
Pattern pattern = Pattern.compile(regExpPattern);
String result = ""; for (int i = 0; i < stringArray.length; i++) {
String string = stringArray[i]; if (string != null) { // Create matcher for this string
Matcher matcher = pattern.matcher(string); if (matcher.find()) {
result = string; break;
}
}
} return result;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.