String text = the property value [[some.text]] and [[value2.value]]should be replaced.
值[[some.some]]
应替换为一些动态代码。
String entryValue = entry.getValue();
Pattern pattern = Pattern.compile("([[\\w]])");
Matcher matcher = pattern.matcher(entryValue);
while(matcher.find()){
String textToReplace = matcher.group(1);
textToReplace = textToReplace.replace(".","");
String resolvedValue = "text to be replaced";
matcher.replaceAll(resolvedValue);
}
答案 0 :(得分:1)
转义[ and ]
因为这些是特殊的正则表达式符号:
Pattern pattern = Pattern.compile( "(\\[\\[[\\w.]*\\]\\])" );