mysql replace first_Java replaceFirst()方法
Java replaceFirst()方法
replaceFirst() 方法使用給定的參數 replacement 替換字符串第一個匹配給定的正則表達式的子字符串。
語法
publicStringreplaceFirst(Stringregex,Stringreplacement)
參數 regex -- 匹配此字符串的正則表達式。
replacement -- 用來替換第一個匹配項的字符串。
返回值
成功則返回替換的字符串,失敗則返回原始字符串。
實例
public class Test {
public static void main(String args[]) {
String Str = new String("hello santii,I am from santii。");
System.out.print("返回值 :" );
System.out.println(Str.replaceFirst("santii", "google" ));
System.out.print("返回值 :" );
System.out.println(Str.replaceFirst("(.*)santii(.*)", "google" ));
}
}
以上程序執行結果為:
返回值 :hello google,I am from santii。
返回值 :google
本文網址:http://www.santii.com/java/java-string_replacefirst.html
總結
以上是生活随笔為你收集整理的mysql replace first_Java replaceFirst()方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 反内卷神器!360要上线“一键强制下班”
- 下一篇: linux cmake编译源码,linu