//定义一个方法,把超过四个数字部分替换成#
public static void replaceDemo(){ String str = "agld254125874dfd"; String reg = "\\d{4, }"; str = str.replaceAll(reg, "#"); System.out.println(str); }
就这么一个简单的正则表达式,主方法调用此方法,运行后出现异常:Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed counted closure near index 5 \d{4, } ....................
求解!谢谢