fm.get('Order__'
我使用類似語法來替代的
fm.get('Order#
都精確匹配在一個漫長的字符串:
String calcStr = "return fm.get('Order#');";
String fname = "Order#";
String validfName = "Order__";
String modifiedCalc1 = calcStr.replaceAll("fm.get('"+fname+"\\b", "fm.get('"+validfName);
System.out.println(modifiedCalc1);
但我得到模式錯誤。
Exception in thread "main" java.util.regex.PatternSyntaxException:
Unclosed group near index 18
\bfm.get('Order#\b
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.accept(Unknown Source)