class RegDemo7
{
public static void main(String[] args)
{
String str="dhif83643fjgtw433y232";
regReplace(str,"\\d{2,}","$");
}
public static void regReplace(String str,String reg,String newStr)
{
str=str.replaceAll(reg,newStr);
System.out.println(str);
}
}
想把字符串中的数字都替换成“$”,为什么报错啊?难道替换方法写错了? |
|