62,616
社区成员
发帖
与我相关
我的任务
分享
String str = "<script>parent.setGoalAlertStatus(false);parent.od_Data[1].s = [4303];parent.od_Data[1].c = [[[4,'ITALY SERIE A',0], [ [722901,'Brescia','Inter Milan','1.010',6,'03/12/2011 03:45',0,4,1,0,'SG: CH202
MY: ASTRO816
IDN]]]]];have more chars";
//字符串的内容是多变的,这里只是举个例子。
String str = "<script>parent.setGoalAlertStatus(false);parent.od_Data[1].s = [4303];parent.od_Data[1].c = [[[4,'ITALY SERIE A',0], [ [722901,'Brescia','Inter Milan','1.010',6,'03/12/2011 03:45',0,4,1,0,'SG: CH202
MY: ASTRO816
IDN]]]]];have more chars";
Pattern p = Pattern.compile(".+(\\[\\[.+\\]\\]\\]\\]\\]).+");
Matcher m = p.matcher(str);
while(m.find()){
System.out.println(m.group(1));
}
public static void main(String[] args) {
String str = "<script>parent.setGoalAlertStatus(false);parent.od_Data[1].s = " +
"[4303];parent.od_Data[1].c = [[[4,'ITALY SERIE A',0], [ [722901" +
",'Brescia','Inter Milan','1.010',6,'03/12/2011 03:45',0,4,1,0,'SG: CH202&" +
"#13;MY: ASTRO816
IDN]]]]];have more chars";
String regex = "\\[{2,}.*\\]{2,}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
while(m.find()) {
System.out.println(m.group());
}
}