# Re: Equivalent of Python zfill?

**URL:** <https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95341>\
**Category:** Ruby\
**Created:** [May 29, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95341 "2006-05-29T12:16:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 29, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95341/1 "2006-05-29T12:16:11Z")

</div>

fr Peter:

# in Python this function is ‘’.zfill(5)

# another possibility would be 5\*‘0’

# 

# Equivalents in Ruby? I would be mainly interested in a zfill

# equivalent

# since that is faster that join or 5\* imho.

same here.

irb(main):043:0\> ‘0’\*5  
=\> “00000”  
irb(main):044:0\> ‘0’\*3  
=\> “000”
