Hello, does anybody know a simple way to strip the leading zeros out of a string?

I have tried

userName.replaceFirst("^0+(?!$)", "");

but cant seem to make it work, any ideas?


correction, this work..

userName = userName.replace("0", "");

That will remove all zeros though, regardless of position. Is that what you intend? replaceAll("^0*", "") will remove just the leading ones.