第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

用java中的另一個(gè)字符串替換字符串

用java中的另一個(gè)字符串替換字符串

慕村225694 2019-07-03 10:19:58
用java中的另一個(gè)字符串替換字符串什么函數(shù)可以用另一個(gè)字符串替換一個(gè)字符串?示例1:什么將取代"HelloBrother"帶著"Brother"?示例2:什么將取代"JAVAISBEST"帶著"BEST"?
查看完整描述

3 回答

?
偶然的你

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊

這個(gè)replace方法就是你要找的東西。

例如:

String replacedString = someString.replace("HelloBrother", "Brother");


查看完整回答
反對(duì) 回復(fù) 2019-07-03
?
慕絲7291255

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

可以在以下方法中將一個(gè)字符串替換為另一個(gè)字符串

方法1:使用字符串replaceAll

 String myInput = "HelloBrother";
 String myOutput = myInput.replaceAll("HelloBrother", "Brother"); // Replace hellobrother with brother
 ---OR---
 String myOutput = myInput.replaceAll("Hello", ""); // Replace hello with empty
 System.out.println("My Output is : " +myOutput);

方法2*使用Pattern.compile

 import java.util.regex.Pattern;
 String myInput = "JAVAISBEST";
 String myOutputWithRegEX = Pattern.compile("JAVAISBEST").matcher(myInput).replaceAll("BEST");
 ---OR -----
 String myOutputWithRegEX = Pattern.compile("JAVAIS").matcher(myInput).replaceAll("");
 System.out.println("My Output is : " +myOutputWithRegEX);

方法3*使用Apache Commons如以下鏈接所定義:

 
 java.lang.String, java.lang.String)

參照系


查看完整回答
反對(duì) 回復(fù) 2019-07-03
  • 3 回答
  • 0 關(guān)注
  • 2965 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)