All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cucumber.runtime.Shellwords Maven / Gradle / Ivy

There is a newer version: 7.18.0
Show newest version
package cucumber.runtime;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Shellwords {
    private static final Pattern SHELLWORDS_PATTERN = Pattern.compile("[^\\s']+|'([^']*)'");

    private Shellwords() {
    }

    public static List parse(String cmdline) {
        List matchList = new ArrayList();
        Matcher shellwordsMatcher = SHELLWORDS_PATTERN.matcher(cmdline);
        while (shellwordsMatcher.find()) {
            if (shellwordsMatcher.group(1) != null) {
                matchList.add(shellwordsMatcher.group(1));
            } else {
                matchList.add(shellwordsMatcher.group());
            }
        }
        return matchList;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy