replaceall

    -2熱度

    2回答

    我有一個字符串「Home 333-666-8888請勿打擾」,並且希望從字符串中提取數字。爲此,我找到了Java中的ReplaceAll功能的解決方案。 String ab="Home 333-666-8888 Do Not Disturb"; String bc=ab.replaceAll("[^0-9-]", ""); ,這讓我333-666-8888 我關心的是如何replaceAl

    1熱度

    2回答

    我正在嘗試查找正則表達式。 我有這樣的: String regex_words_ended_s_in_singular_form = "\\b(anglais|francais)\\b"; 然後,我想在除了「英語」和「法蘭西」的所有詞的結尾刪除的「。 我想這一點,但它並沒有當然的工作: String temp = tweet.replaceAll("(?!" + regex_words_end

    0熱度

    1回答

    我想更改使用下劃線作爲字每一個詞,沒有下劃線,但以一個大寫 例子:new_york - >紐約 到目前爲止我的解決辦法是寫的每一封信一條線,這是不非常高效: mySolution = mySolution.replaceAll("_a", "A"); 編輯:這個問題是關於在一行中使用ReplaceAll,因此與其他問題無關。我可以管理編寫一個「長」程序,但我想大多數用戶會很樂意爲這個問題得到實

    -3熱度

    2回答

    我有一些代碼,看起來像這樣: str.replaceAll('$', ' '); return str; 我想要做的,是取代$每個實例都在我的字符串str用空間。但是,我得到這個錯誤,當我編譯: incompatible types: char cannot be converted to String str.replaceAll('$', ' '); ^

    0熱度

    4回答

    我試圖改變'18 rue D'armenie'或'25 boulevard D'armes'在'Armenie街18號'或'25'boulevard d'Armes'中的字符串。 如何String.replace這個改變? 我目前做的是這樣的: WordUtils.capitalizeFully(street.trim()).replace(" D'", " d'"); 我想添加第二個代替做這

    1熱度

    1回答

    我必須用%20來替換字符串中的所有空格。 我嘗試使用方法replaceAll在此模式下title.replaceAll(" ", "%20");(顯然的標題是一個字符串),但這並不工作,結果是初始字符串中的所有空白

    -1熱度

    4回答

    我試圖顛倒整個字母順序A-Z→Z-A。 這是我到目前爲止。 public class Program { public static voud main(String[] args) { String text = "Hi My name is Dave\n"; text = text.replaceAll("[a-z ]",["z-a"]);

    -3熱度

    1回答

    public String plusOut(String str, String word){ String bob = str.replaceAll(^word,"+"); return bob; } 樣品輸入和輸出: 我要替換字符串(STR)的一切,這不是字符串(字)與+ plusOut("1234xy5678", "xy") == "++++xy++++" plusOut

    1熱度

    3回答

    在java中1.8.0 我試圖取代%,但它不匹配 String str = "%28Sample text%29"; str.replaceAll("%29", "\\)"); str.replaceAll("%28", "\\("); System.out.println("Replaced string is " + str); 我已經嘗試了所有這Repl

    0熱度

    1回答

    我試圖捕獲Java中行中的最後一個屬性。請調整下面的代碼,並幫助我找到「battr」。例如,我命名屬性如「attr」和「battr」,但它可以是任何東西。 System.out.println("<tag attr=\"val1\" battr=\"val2\"></tag>".replaceAll(".*([a-z]+\\s*=).*","$1"));