Dear Statalist users

I have a dataset which has a string variable in three parts, by convention, separated by a hyphen: e.g. 12345-2020-0001
The last part is designed to run serially from 0001 to 9999. However, the dataset has observations with extra zeros like -00001or -00045 instead of -0001 and -0045 respectively.
I would like to remove one of the zeros in -00001 and -00045
I have tried the command below without success

local var1 "stringvar"
foreach r of local var1 {
replace `r' =subinstr(`r',"`-000??'","`-00??'",.)
}

I am using Stata SE version 16.1 for Mac

Can someone help me with a solution.
Thank you
Mutugi Muriithi