日期:2014-05-20 浏览次数:20575 次
Pattern p = Pattern.compile("var a = \\$\\{(.*)\\}.*?var b = (\\$\\{(.*)\\})"); String strs = "<script> var a = ${\"aaaa\"}; var b = ${?}; </script>"; Matcher m = p.matcher(strs); String strs2 = ""; while(m.find()) { strs2 = m.group(2); String test1 = "\\"+m.group(3); String test2 = m.group(1); strs2 = strs2.replaceAll(test1, test2); } System.out.println(strs2);