解析command字符串中有效命令

阅读更多

job create --name Job_name_xxx_test --definition 'triggerCeModule --dateFormat=yyyy-MM-dd --projectName=xxx' --deploy

 

Matcher nameMatcher = Pattern.compile("--name.+--definition").matcher(line);
if (nameMatcher.find()) {
    name = nameMatcher.group(0);
}
name = name.replace("--name", "").replace("--definition", "").trim();

Matcher definitionMatcher = Pattern.compile("'.+'").matcher(line);
if (definitionMatcher.find()) {
    definition = definitionMatcher.group(0);
}
definition = definition.substring(1, definition.length() - 1).trim();

 

解析name=Job_name_xxx_test, definition=triggerCeModule --dateFormat=yyyy-MM-dd --projectName=xxx

 

 

 

你可能感兴趣的:(Matcher,Pattern)