大家来看看找个unicode转码的问题
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test{
public static void main(String[] args){
String aa = "&#大家来看离开家地方军离开家地方里克斯都是可分解家";
replaceUnicodeScalarValue(aa);
}
private static String replaceUnicodeScalarValue(String result) {
Pattern scalarValue = Pattern.compile("(&#(\\d*?);)");
Matcher scalarValueMatcher = scalarValue.matcher(result);
while(scalarValueMatcher.find()) {
result = scalarValueMatcher.replaceFirst(String.valueOf((char)Integer.parseInt(scalarValueMatcher.group(2))));
System.out.println(result);
scalarValueMatcher = scalarValue.matcher(result);
}
return result;
}
请教高手group(2)什么意思 为什么group(2)才可以匹配到 group(0) group(1) 都不可以
API 这样说返回在以前匹配操作期间由给定组捕获的输入子序列。
可还是不太明白...