Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
No such thing as a small change
 
PerlMonks  

Re: Removing leading zeros

by FouRPlaY (Monk)
on May 14, 2001 at 20:34 UTC ( [id://80335]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Removing leading zeros

I'd do it with a regex like:

s/^0+//g



FouRPlaY
Learning Perl or Going To die() Trying

Replies are listed 'Best First'.
Re^2: Removing leading zeros
by Anonymous Monk on Apr 22, 2019 at 11:07 UTC
    That RE fails multiple edge cases. It will change "0", or "00", etc. into "" making it non-numeric. And not handling the negative case has already been mentioned.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://80335]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.