解析command字符串中有效命令
程序员文章站
2022-04-22 12:09:33
...
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