"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Regarding the (\d)(\d) repitition you are using, I highly recommend you pick up a copy of "Learning Perl" and "Programming Perl" -- the O'Reilly Camel and Lllama books, as these explain regexes, and the fact tht you can do things like (\d{0..9}) or (\d*) to specifiy a certain number of digits.
It always helps to read a little documentation before charging too deeply into new things! :) While the 'don't use regexes' comments are 100% right, a regex cleanup solution could look something like $x=~s/[0]?(\d+)/$1/;. The question mark means 'optional', and the '+' means 'one or more of'. The $1 represents what you matched inside parens between the first set of slashes. So we are replacing digits with a leading zero with just the digits. Again, read the docs, they are excellent. (as usual, all code is untested) In reply to Re: Regex and leading zeros in numbers
by flyingmoose
|
|