📌  相关文章
📜  java代码示例中如何用字符串中的另一个字符替换一个字符

📅  最后修改于: 2022-03-11 14:52:18.339000             🧑  作者: Mango

代码示例2
public class JavaExample{
   public static void main(String args[]){
    String str = new String("Site is BeginnersBook.com");

    System.out.print("String after replacing com with net :" );
    System.out.println(str.replaceFirst("com", "net"));

    System.out.print("String after replacing Site name:" );
    System.out.println(str.replaceFirst("Beginners(.*)", "XYZ.com"));
   }
}