我想了解下面的內容。瞭解這個正則表達式
^([^=]+)(?:(?:\\=)(.+))?$
任何想法?
這是在這裏使用。顯然它是命令行解析器,但我試圖理解語法,所以我實際上可以運行該程序。這是從commandline-jmxclient,他們沒有設置JMX屬性的文件,但在他們的源代碼中,有這樣的選項,所以我只想了解我可以如何調用該方法。
Matcher m = Client.CMD_LINE_ARGS_PATTERN.matcher(command);
if ((m == null) || (!m.matches())) {
throw new ParseException("Failed parse of " + command, 0);
}
this.cmd = m.group(1);
if ((m.group(2) != null) && (m.group(2).length() > 0))
this.args = m.group(2).split(",");
else
this.args = null;
兩個最佳答案都是正確的(Dmitry's和FailedDev's)。應該指出的是,這個正則表達式可以簡化爲 –