1
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);
}
難道你需要兩個反斜槓? –
噢,是的,糾正它。謝謝。 – anubhava
你不需要轉義'''id它沒有打開並且沒有轉義'''在它之前。 – Pshemo