No. | 方法名称 | 类型 | 描述 |
1 | public String replaceAll(String regex,String replasement) | 普通 | 用新的内容替换全部旧内容 |
2 | public String replaceFirst(String regex,String replacement) | 普通 | 替换首个满足条件的内容 |
public class Demo {
public static void main(String[] args) {
String str = "helloworld";
String strA = str.replaceAll("l", "@");
String strB = str.replaceFirst("l", "*");
System.out.println(strA);
System.out.println(strB);
}
}