Removing Dollar and comma from string
Without regex, you can try this:
String output = "$123,456.78".replace("$", "").replace(",", "");
do like this
NumberFormat format = NumberFormat.getCurrencyInstance();
Number number = format.parse("\$123,456.78");
System.out.println(number.toString());
output
123456.78
Try,
String liveprice = "$123,456.78";
String newStr = liveprice.replaceAll("[$,]", "");
replaceAll
uses regex, to avoid regex than try with consecutive replace
method.
String liveprice = "$1,23,456.78";
String newStr = liveprice.replace("$", "").replace(",", "");
Here is more information Oracle JavaDocs:
liveprice = liveprice.replace("X", "");