我得到的輸出是打印x
的值,剩下的兩個println
打印出空白行。這個replaceAll()有什麼問題?
1.234.567,89
Process finished with exit code 0
我在做什麼錯?
public class Dummy {
public static void main(String args[]) {
String x = "1.234.567,89 EUR";
String e = " EUR";
x = x.replaceAll(" EUR","");
System.out.println(x);
x = x.replaceAll(".", "");
System.out.println(x);
x = x.replaceAll(",",".");
System.out.println(x);
//System.out.println(x.replaceAll(" EUR","").replaceAll(".","").replaceAll(",","."));
}
}
使用'x = x.replaceAll(「[。]」,「」);'第一個參數是一個正則表達式。 –
你究竟想要做什麼? –