String s =" Platform Software
VRP (R) software, Version 8.100 (CE6850EI V100R005C10)
Copyright (C) 2012-2015 Technologies Co., Ltd.HUAWEI CE6850-48T4Q-EI uptime is 1 day, 2 hours, 57 minutes CE6850-48T4Q-EI(Master) 3 : uptime is 1 day, 2 hours, 57 minutes
StartupTime 2015/02/04 09:07:56
Memory Size : 2048 M bytes
Flash Size : 1024 M bytes
NVRAM Size : 512 K bytes
我想取 第二个圆括号中的值CE6850EI V100R005C10,这个正则怎么写啊?
------解决思路----------------------
final String REGEX=".*(\\(.*\\))Copyright.*";
String str1="Platform SoftwareVRP (R) software, Version 8.100 (CE6850EI V100R005C10)Copyright (C) 2012-2015 Technologies Co., Ltd.HUAWEI CE6";
Matcher m=Pattern.compile(REGEX, Pattern.CASE_INSENSITIVE).matcher(str1);
if(m.find()){
System.out.println(m.group(1).replace("(", "").replace(")", ""));
}
------解决思路----------------------
Matcher m=Pattern.compile(".*?\\).*?\\(([^)]*?)\\)").matcher(s);
if(m.find())System.out.println(m.group(1));
------解决思路----------------------
好多写法啊,来个最笨的
Pattern pattern = Pattern.compile("Version 8.100\\s+\\((.*)\\)Copyright");
Matcher matcher = pattern.matcher(s);
StringBuffer sbr = new StringBuffer();
if (matcher.find()) {
System.out.println(matcher.group(1));
------解决思路----------------------
String str1="Platform SoftwareVRP (R) software, Version 8.100 (CE6850EI V100R005C10)Copyright (C) 2012-2015 Technologies Co., Ltd.HUAWEI CE6";
int i = str1.indexOf("(",str1.indexOf("(")+1);
int j = str1.indexOf(")",str1.indexOf(")")+1);
String str2 = str1.substring(i+1,j);
System.out.println(str2);