📌  相关文章
📜  替换字符串中的字符java代码示例

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

代码示例4
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"));
   }
}