Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I would like a regex to replace leading zeroes in a number. For example, a ten-digit number string has 5 leading (leftmost) zeroes. I would like to replace each leading zero with a space, i.e. 5 leading zeroes with 5 leading spaces. I tried s/^0+/ /g but it replaced all leading zeroes with only one space character. How may I accomplish this?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Answer: How do I zero-suppress a number?
by merlyn (Sage) on Dec 29, 2000 at 20:22 UTC