我一直在寻找一段时间试图弄清楚为什么这不起作用 - 我找到了我想要完成的确切事情简单的正则表达式替换以保留原始字符串,但我似乎无法使用正则表达式$+
或$&
在 Java 中像这样:
String S1 = "bob";
String S2 = "the builder";
Pattern p = Pattern.compile(S1, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(ST);
ST = m.replaceAll("$+/"+S2);