public void testOne() {
Set<String> set = new HashSet();
Pattern p = Pattern.compile("[{,](.+?)[=]");
Pattern p1 = Pattern.compile("[=]([^\\[]+?)[\\},]");
Matcher matcher = p.matcher(m);
Matcher matcher1 = p1.matcher(m);
while (matcher.find()) {
System.out.println(matcher.group(1));
set.add(matcher.group(1).trim());
}
while (matcher1.find()) {
System.out.println(matcher1.group(1));
set.add(matcher1.group(1).trim());
}
for (String s : set) {
m = m.replaceAll("\\b"+s+"\\b", "\"" + s + "\"");
}
m=m.replaceAll("=", ":");
System.err.println(m);
}
正则map和json?
最新推荐文章于 2024-09-15 22:21:10 发布