String s=”str123str”;
String hello=s.replace(“str”,”hello”);
System.out.println(“hello:+hello);//输出结果:hello123hello
String s1=”str123st.r”;
String hello1=s1.replace(“\\.”,””);//\\进行转义
System.out.println(“hello1:+hello1);//输出结果:str123str
String s2=”str123str”;
String hello2=s.replaceFirst(“str”,”hello”);
System.out.println(“hello2:+hello2);//输出结果:hello123str