标签: java regex string
我想在String中匹配模式后添加一些文本。我怎样才能做到这一点? 例如:String text = text.replaceAll("a[0-9]*z",???+"ADDED"); // a123z -> a123zADDED
String text = text.replaceAll("a[0-9]*z",???+"ADDED"); // a123z -> a123zADDED
答案 0 :(得分:5)
String text = text.replaceAll("a[0-9]*z", "$0ADDED");
另见:
Matcher.appendReplacement()