Wrong output using replaceall

后端 未结 4 860
误落风尘
误落风尘 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:15

    Because every single char of the input matches the regexp pattern (.). To replace dots, use this pattern: \. (or as a Java String: "\\.").

提交回复
热议问题