I want to convert GBP 29.15*
to just 29.15
.
Can anyone please help?
I have already tried parsing to integer/float, substring etc. but getting an error.
I want to convert GBP 29.15*
to just 29.15
.
Can anyone please help?
I have already tried parsing to integer/float, substring etc. but getting an error.
Try this:
float f = Float.valueOf("GBP 29.15*".replaceAll("[^\\d.]+|\\.(?!\\d)", ""));
It removes all non-number characters and then finds the float value.
See also: How to get float value from string