Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pad digits and regular expressions

Status
Not open for further replies.

zackiv31

Programmer
Joined
May 25, 2006
Messages
148
Location
US
Say I want a number to be 6 digits, and its 50... I want to pad it with zeros on the left. Is there a way to do this, or should I just do a length and then pad blahblah...

Also,

Does anyone know how to do repeating in perl regular expressions? Like say I want to find any repetition of dog 100 times in a string, but not (dog)+ Is there a way to do this?
 
Code:
$string=50;
$string=sprintf("%0.6d", $string);

2nd question, definitive resource on regexes

HTH
--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top