日期:2014-05-20 浏览次数:20903 次
public static void main(String[] args) {
String str = "今天1000天可是(267国)";
str = str.replaceAll(".*?\\(.*?(\\d+).*?\\)","$1");
System.out.println(str);
}
------解决方案--------------------
for example
String s = "今天1000天可是(267国)";
Pattern p = Pattern.compile("[(].*?(\\d+).*?[)]");
Matcher m = p.matcher(s);
while (m.find()) {
System.out.println(m.group(1));
}