private static void output(String s1) { System.out.println("============================================="); System.out.println(s1); Pattern pattern = Pattern.compile("(?<==)([^,])+(?=,*)"); Matcher matcher = pattern.matcher(s1.toString()); int i = 0; while (matcher.find()) { System.out.println(++i+"\t"+matcher.toMatchResult().group()); } System.out.println("============================================="); }
将a=1,b=2,c=3这类数据直接获取values
通过正则表达式向后引用实现。