>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?


Opps.  Not quite right.  The regex should be s/0/ /g

My test code:

print $num = "000001\n";

$num =~ (s/0/ /g);

print $num;


which prints

000001
            1

Joel


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to