日期:2014-05-20 浏览次数:21054 次
public static void main(String[] args) { String s ="resultStatus={9000};memo={1};result={temp}" ; s= s.replaceAll("=", " ") ; s= s.replaceAll("[\\{\\}]", " ") ; String[] ss = s.split(";") ; for (int i = 0; i < ss.length; i++) { System.out.println(ss[i]); } }
------解决方案--------------------
String s = "resultStatus={9000};memo={1};result={temp}"; Pattern p = Pattern.compile("([^;]*?)\\=\\{(.*?)\\}"); Matcher m = p.matcher(s); while (m.find()) { System.out.println(m.group(1) + " = " + m.group(2)); }