Wrong output using replaceall

后端 未结 4 876
误落风尘
误落风尘 2021-01-16 03:20

Why do i get \"AAAAAAAAA\" instead of \"1A234A567\" from following Code:

String myst = \"1.234.567\";

String test = myst.replaceAll(\".\", \"A\");

System.o         


        
4条回答
  •  半阙折子戏
    2021-01-16 04:18

    You need to escape .

    make it

    String myst = "1.234.567";
    
    String test = myst.replaceAll("\\.", "A");
    
    System.out.println(test);
    

提交回复
热议问题