1)通过\1来引用第一个组中的public static void main(String[] args) {
String content="
hello world!";String regextStr=".*?\\1>";
Pattern pattern=Pattern.compile(regextStr, Pattern.CASE_INSENSITIVE);
Matcher matcher =pattern.matcher(content);
if(matcher.find()){
System.out.println(matcher.group());
}else{
System.out.println("no found");
}
}
2)通过$1等来引用str = str.replaceAll("", "
@@IMGGROUP=\"" + channelid + "|$1\"@@
");