I am having a String str = "12.12 is a float number."
I want to replace the .(Dot) with ,(comma) for decimal number calculation,
Currently i am trying this :
system.out.println(str.replaceAll("\\d+\\.\\d+", "\\d+\\,\\d+"));
target output: "12,12 is a float number."
please help
You have to use capturing groups:
str.replaceAll("(\\d+)\\.(\\d+)", "$1,$2")
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments