国内十个免费自学网站,阿里绿网网站违规,北京轨道交通建设管理有限公司网站,网站建设设备清单Java replaceFirst()方法replaceFirst() 方法使用给定的参数 replacement 替换字符串第一个匹配给定的正则表达式的子字符串。语法publicStringreplaceFirst(Stringregex,Stringreplacement)参数 regex -- 匹配此字符串的正则表达式。replacement -- 用来替换第一个匹配项的字符…Java replaceFirst()方法replaceFirst() 方法使用给定的参数 replacement 替换字符串第一个匹配给定的正则表达式的子字符串。语法publicStringreplaceFirst(Stringregex,Stringreplacement)参数 regex -- 匹配此字符串的正则表达式。replacement -- 用来替换第一个匹配项的字符串。返回值成功则返回替换的字符串失败则返回原始字符串。实例public class Test {public static void main(String args[]) {String Str new String(hello santiiI am from santii。);System.out.print(返回值 : );System.out.println(Str.replaceFirst(santii, google ));System.out.print(返回值 : );System.out.println(Str.replaceFirst((.*)santii(.*), google ));}}以上程序执行结果为返回值 :hello googleI am from santii。返回值 :google本文网址http://www.santii.com/java/java-string_replacefirst.html