当前位置: 代码迷 >> 综合 >> Java 的 replaceFirst(String regex, String replacement)
  详细解决方案

Java 的 replaceFirst(String regex, String replacement)

热度:18   发布时间:2023-12-22 04:25:29.0

replaceFirst(string1,string2)

String str = "www.123.com www.123.com";
System.out.println(str.replaceFirst("123", "baidu"));

输出结果为:

www.baidu.com www.123.com

replaceFirst(str1,str2)用str2替换str1第一次出现地方,并返回新字符串。

  相关解决方案