Homework
Topic sourcestatic String replaceByMap(String source, Map<String, String> rule) { Pattern p = Pattern.compile("\\$\\{[a-zA-Z]+}"); Matcher matcher = p.matcher(source); StringBuilder s = new StringBuilder(); while (matcher.find()){ String temp = source.substring(matcher.start(),matcher.end()); matcher.appendReplacement(s,rule.get(temp.substring(2,temp.length()-1))); } return s.toString();}
- 1
0刘俊铖