0
(cl(A, B, 0.620) :- /* #pos=1,513 *
預期輸出:
Fetch and Add A and B to a list
碼(嘗試1):
Matcher m2 = Pattern.compile("\\((.*?)\\)").matcher(inputString);
while(m2.find())
{
System.out.println(m2.group(1));
}
輸出:
cl(A, B, 0.620
代碼嘗試2:
System.out.println(inputString.substring(inputString.indexOf("(")+1,inputString.indexOf(")")));
仍然得到相同的輸出。
請告訴我什麼是錯誤。
你能解釋一下嗎? –
你從第一個打開的括號與第一個閉括號相匹配 - 你(似乎)需要實際解析字符串來匹配開括號和右括號 – UnholySheep
@MaulikDoshi用例是獲取palenthesis中的參數。 –