|
@@ -159,7 +159,9 @@ public class CommandArguments {
|
159
|
159
|
* @return A String representation of the requested words
|
160
|
160
|
*/
|
161
|
161
|
public String getWordsAsString(final int start) {
|
162
|
|
- return getWordsAsString(start, words.length);
|
|
162
|
+ parse();
|
|
163
|
+
|
|
164
|
+ return getWordsAsString(start, words.length - 1);
|
163
|
165
|
}
|
164
|
166
|
|
165
|
167
|
/**
|
|
@@ -172,10 +174,10 @@ public class CommandArguments {
|
172
|
174
|
*/
|
173
|
175
|
@Precondition("Start index is less than or equal to end index")
|
174
|
176
|
public String getWordsAsString(final int start, final int end) {
|
175
|
|
- Logger.assertTrue(start <= end);
|
|
177
|
+ Logger.assertTrue(start <= end + 1);
|
176
|
178
|
|
177
|
179
|
final Pattern pattern = Pattern.compile("(\\S+\\s*){" + (start) + "}"
|
178
|
|
- + "((\\S+\\s*){" + (end - start) + "}).*?");
|
|
180
|
+ + "((\\S+\\s*){" + Math.max(0, end - start) + "}\\S+).*?");
|
179
|
181
|
final Matcher matcher = pattern.matcher(line);
|
180
|
182
|
|
181
|
183
|
return matcher.matches() ? matcher.group(2) : "";
|