String s = "Length(1-2), Width(3-4), Height(5-6)"
我只需要获取括号内的值,即-
[1-2, 3-4, 5-6]
当我使用s.split("\\((.*?)\\)")
时,我在括号外得到了值,但我需要在括号里。我该怎么做呢?
发布于 2018-12-06 18:07:35
String s = "Length(1-2), Width(3-4), Height(5-6)";
Pattern p = Pattern.compile("\\((.*?)\\)");
Matcher m = p.matcher(s);
while(m.find()) {
System.out.println(m.group(1));
}
https://stackoverflow.com/questions/53648787
复制相似问题