问题描述
Strings=[{id:1234,name:sun,content:[100,20,30,50]},{id=456,name:luo,content:[70,90,80,60]}]我是想通过逗号来分隔,可是content里面也有逗号,请问怎么办?最终:id:1234name:suncontent:[100,20,30,50]谢谢了!
解决方案
解决方案二:
publicstaticvoidmain(String[]args){Strings="[{id:1234,name:sun,content:[100,20,30,50],content:[100,20,30,50]},{id=456,name:luo,content:[70,90,80,60]}]";Matcherm=Pattern.compile("\{(.*?)\}").matcher(s);while(m.find()){Stringstr=m.group(1);System.out.println(str);Stringarr[]=str.split(",(?=[^,]*:)");System.out.println(arr.length+","+java.util.Arrays.toString(arr));}}
时间: 2024-10-29 06:35:38