I have a string SG0P01, and I want to convert it to a decimal 0.01, the P is the decimal place. I am not sure how to do this. I have tried using .replace, re, etc but cant figure it out.
string = "SG0P01"
dec = string.replace("P",".")
This results in SG0.01, now I just need to get rid of the SG, I tried using re.sub('\D','',dec) but that removes the decimal as well. Is there a way to preserve the decimal, or just do this entire thing in a better way?