日期:2014-05-17 浏览次数:20922 次
String prefix="../../";
String source="window.parent.getNodeCodeByUrl(\"as/as/s.json\")" ;
String result=source.replaceAll("window\\.parent\\.getNodeCodeByUrl\\(\"(.*?)\\.json\"\\)","window.location.href=\""+prefix+"$1.html\"");
System.out.println(result);
------解决方案--------------------
上面的漏了双引号了
不要动态的,那就直接写
String str = "window.parent.getNodeCodeByUrl(\"ac/bc/as/b.json\");";
str = str.replaceAll("(?i)window[.]parent[.]getNodeCodeByUrl[(]\"(.*?)/(.*?)[.]json\"[)].*", "windon.location.href=\"../../../$1/page/$2.html\";");
System.out.println(str);