mysql replace first_Java replaceFirst()方法
Java replaceFirst()方法
replaceFirst() 方法使用給定的參數(shù) replacement 替換字符串第一個(gè)匹配給定的正則表達(dá)式的子字符串。
語(yǔ)法
publicStringreplaceFirst(Stringregex,Stringreplacement)
參數(shù) regex -- 匹配此字符串的正則表達(dá)式。
replacement -- 用來(lái)替換第一個(gè)匹配項(xiàng)的字符串。
返回值
成功則返回替換的字符串,失敗則返回原始字符串。
實(shí)例
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" ));
}
}
以上程序執(zhí)行結(jié)果為:
返回值 :hello google,I am from santii。
返回值 :google
本文網(wǎng)址:http://www.santii.com/java/java-string_replacefirst.html
總結(jié)
以上是生活随笔為你收集整理的mysql replace first_Java replaceFirst()方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 反内卷神器!360要上线“一键强制下班”
- 下一篇: 赢了!中芯国际宣布在美国胜诉:原告不得再