Reputation: 845
String text = the property value [[some.text]] and [[value2.value]]should be replaced.
The values [[some.some]]
should be replaced with some dynamic code.
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);
}
Upvotes: 1
Views: 114
Reputation: 785038
Escape [ and ]
as these are special regex symbols:
Pattern pattern = Pattern.compile( "(\\[\\[[\\w.]*\\]\\])" );
Upvotes: 1