正则表达式使用 java 代码 Pattern pattern = Pattern.compile("\\-\\w+ \\w+"); Matcher match = pattern.matcher(command); while (match.find()) { System.out.println(match.group()); }