|
@@ -22,6 +22,9 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.commandparser;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.Precondition;
|
|
26
|
+import com.dmdirc.logger.Logger;
|
|
27
|
+
|
25
|
28
|
import java.util.Arrays;
|
26
|
29
|
import java.util.regex.Matcher;
|
27
|
30
|
import java.util.regex.Pattern;
|
|
@@ -144,7 +147,10 @@ public class CommandArguments {
|
144
|
147
|
* @param end The index of the last word to include
|
145
|
148
|
* @return A String representation of the requested words
|
146
|
149
|
*/
|
|
150
|
+ @Precondition("Start index is less than or equal to end index")
|
147
|
151
|
public String getWordsAsString(final int start, final int end) {
|
|
152
|
+ Logger.assertTrue(start <= end);
|
|
153
|
+
|
148
|
154
|
final Pattern pattern = Pattern.compile("(\\S+\\s*){" + (start) + "}"
|
149
|
155
|
+ "((\\S+\\s*){" + (end - start) + "}).*?");
|
150
|
156
|
final Matcher matcher = pattern.matcher(line);
|