日期:2014-05-19 浏览次数:20741 次
public static void main(String[] args) { String testStr = "{\"A0\":\"2011-10-11 12:08:06:This is the first message\",\"A1\":\"2011-10-11 12:08:06:This is the second message\"}"; String reg = "\"A[\\d]+\":\"([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}):([^\"]+)\""; Pattern p = Pattern.compile(reg); Matcher matcher = p.matcher(testStr); while (matcher.find()) { System.out.println(matcher.group(1) + " " + matcher.group(2)); } }