@@ -59,49 +59,39 @@ public static Matcher matchOrThrow(@Nonnull final Pattern pattern,
5959 }
6060 }
6161
62- @ Nonnull
63- public static String matchNamedGroup (final String pattern ,
64- final String input ,
65- final String groupName ) throws RegexException {
66- return matchNamedGroup (Pattern .compile (pattern ), input , groupName );
67- }
68-
69- @ Nonnull
70- public static String matchNamedGroup (@ Nonnull final Pattern pattern ,
71- final String input ,
72- @ Nonnull final String groupName ) throws RegexException {
73- return matchOrThrow (pattern , input ).group (groupName );
74- }
75-
76- public static int getStartIndexOfNamedGroup (@ Nonnull final Pattern pattern ,
77- final String input ,
78- @ Nonnull final String groupName )
79- throws RegexException {
80- return matchOrThrow (pattern , input ).start (groupName );
81- }
82-
83- public static int getEndIndexOfNamedGroup (@ Nonnull final Pattern pattern ,
84- final String input ,
85- @ Nonnull final String groupName )
86- throws RegexException {
87- return matchOrThrow (pattern , input ).end (groupName );
88- }
89-
62+ /**
63+ * Matches group 1 of the given pattern against the input
64+ * and returns the matched group
65+ *
66+ * @param pattern The regex pattern to match.
67+ * @param input The input string to match against.
68+ * @return The matching group as a string.
69+ * @throws RegexException If the pattern does not match the input or if the group is not found.
70+ */
9071 @ Nonnull
9172 public static String matchGroup1 (final String pattern , final String input )
9273 throws RegexException {
9374 return matchGroup (pattern , input , 1 );
9475 }
9576
96-
77+ /**
78+ * Matches group 1 of the given pattern against the input
79+ * and returns the matched group
80+ *
81+ * @param pattern The regex pattern to match.
82+ * @param input The input string to match against.
83+ * @return The matching group as a string.
84+ * @throws RegexException If the pattern does not match the input or if the group is not found.
85+ */
9786 @ Nonnull
98- public static String matchGroup1 (final Pattern pattern ,
99- final String input ) throws RegexException {
87+ public static String matchGroup1 (final Pattern pattern , final String input )
88+ throws RegexException {
10089 return matchGroup (pattern , input , 1 );
10190 }
102-
91+
10392 /**
104- * Matches the specified group of the given pattern against the input.
93+ * Matches the specified group of the given pattern against the input,
94+ * and returns the matched group
10595 *
10696 * @param pattern The regex pattern to match.
10797 * @param input The input string to match against.
@@ -110,26 +100,45 @@ public static String matchGroup1(final Pattern pattern,
110100 * @throws RegexException If the pattern does not match the input or if the group is not found.
111101 */
112102 @ Nonnull
113- public static String matchGroup (final String pattern ,
114- final String input ,
115- final int group ) throws RegexException {
103+ public static String matchGroup (final String pattern , final String input , final int group )
104+ throws RegexException {
116105 return matchGroup (Pattern .compile (pattern ), input , group );
117106 }
118-
107+
108+ /**
109+ * Matches the specified group of the given pattern against the input,
110+ * and returns the matched group
111+ *
112+ * @param pattern The regex pattern to match.
113+ * @param input The input string to match against.
114+ * @param group The group number to retrieve (1-based index).
115+ * @return The matching group as a string.
116+ * @throws RegexException If the pattern does not match the input or if the group is not found.
117+ */
119118 @ Nonnull
120119 public static String matchGroup (@ Nonnull final Pattern pattern ,
121120 final String input ,
122- final int group ) throws RegexException {
121+ final int group )
122+ throws RegexException {
123123 return matchOrThrow (pattern , input ).group (group );
124124 }
125125
126+ /**
127+ * Matches multiple patterns against the input string and
128+ * returns the first successful matcher
129+ *
130+ * @param patterns The array of regex patterns to match.
131+ * @param input The input string to match against.
132+ * @return A {@code Matcher} for the first successful match.
133+ * @throws RegexException If no patterns match the input or if {@code patterns} is empty.
134+ */
126135 public static String matchGroup1MultiplePatterns (final Pattern [] patterns , final String input )
127136 throws RegexException {
128137 return matchMultiplePatterns (patterns , input ).group (1 );
129138 }
130139
131140 /**
132- * Matches multiple patterns against the input string and
141+ * Matches multiple patterns against the input string and
133142 * returns the first successful matcher
134143 *
135144 * @param patterns The array of regex patterns to match.
0 commit comments