com.axway.ats.expectj.utils.AtsUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ats-expectj Show documentation
Show all versions of ats-expectj Show documentation
ExpectJ patched by AXWAY ATS Team
The newest version!
package com.axway.ats.expectj.utils;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class AtsUtils {
private static final Pattern COMMAND_ARGUMENTS_PATTERN = Pattern.compile("(?:\\\"[^\\\"]*\\\")|(?:\\'[^\\']*\\')|(?:[^\\s]+)");
public static String[] parseCommandLineArguments(String commandWithArguments) {
ArrayList commandArguments = new ArrayList();
Matcher matcher = COMMAND_ARGUMENTS_PATTERN.matcher(commandWithArguments);
while (matcher.find()) {
String arg = matcher.group();
if (arg.indexOf(34) == 0 && arg.lastIndexOf(34) == arg.length() - 1 || arg.indexOf(39) == 0 && arg.lastIndexOf(39) == arg.length() - 1) {
arg = arg.substring(1, arg.length() - 1);
}
commandArguments.add(arg);
}
return commandArguments.toArray(new String[0]);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy