java replaceAll该怎么用?
的有关信息介绍如下:API如下:
public String replaceAll(String regex, String replacement)
regex: 需要匹配替换的正则
replacement: 将匹配的串替换为此字符串
根据API可知,一个String对象即可调用此API
参考以下例子:
String s = new String("I love programming so much!");
System.out.println(s);//I love programming so much!
s = s.replaceAll("m{1,}", "xxxx_xxxx");
System.out.println(s);//I love progrxxxx_xxxxxxxx_xxxxaing so xxxx_xxxxuch!
那么 tmpString = tmpString.replaceAll("\'", "\\\\'");
官方最新API地址docs.oracle.com/javase/8/docs/api/