I am learning regex and java and working on a problem related to that.
I have an input string which can be any dollar amount like
$123,456.78
$0012,345.67
$123,04.56
$123,45.06
it also could be
$0.1
I am trying to find if the dollar amount has leading zeros and trying to remove it.
so far I have tried this
string result = input_string.replaceAll(("[!^0]+)" , "");
But I guess I'm doing something wrong. I just want to remove the leading zeros, not the ones between the amount part and not the one in cents. And if the amount is $0.1, I don't want to remove it.
.replaceFirst("(?<=\\$)0+(?=\\d)", "")(demo)$0,012.34zeroesis not a typo