komatzu1337 commented on code in PR #1382:
URL: https://github.com/apache/commons-lang/pull/1382#discussion_r2093498092
##########
src/main/java/org/apache/commons/lang3/RegExUtils.java:
##########
@@ -751,4 +755,64 @@ private static String toStringOrNull(final CharSequence
text) {
public RegExUtils() {
// empty
}
+
+
+ public class MatchFinder {
+
+ /**
+ * Finds all matches in the given text according to the specified
pattern.
+ *
+ * @param text the text to search for matches
+ * @param pattern the pattern to search for
+ * @return a list of found matches
+ * @throws IllegalArgumentException if text or pattern is null
+ */
+ public List<String> findMatches(CharSequence text, Pattern pattern) {
+ if (text == null)
+ throw new IllegalArgumentException("Text must not be null");
+
+ if (pattern == null)
+ throw new IllegalArgumentException("Pattern must not be null");
+
+ List<String> matches = new ArrayList<>();
+ Matcher matcher = pattern.matcher(text);
+
+ while (matcher.find()) {
+ matches.add(matcher.group());
+ }
+
+ return Collections.unmodifiableList(matches); // return an
unmodifiable list
+ }
+
+ /**
+ * Finds all matches in the given text according to the specified
pattern.
+ *
+ * @param text the text to search for matches
+ * @param pattern the pattern to search for
+ * @return a list of found matches
+ * @throws IllegalArgumentException if text or pattern is null
+ */
+ public List<String> findMatches(String text, Pattern pattern) {
+ return findMatches((CharSequence) text, pattern);
+ }
Review Comment:
I'll remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]