Using regex to add leading zeroes
Posted
by hgpc
on Stack Overflow
See other posts from Stack Overflow
or by hgpc
Published on 2010-04-17T16:14:41Z
Indexed on
2010/04/17
16:23 UTC
Read the original article
Hit count: 226
regex
|language-agnostic
I would like to add a certain number of leading zeroes (say up to 3) to all numbers of a string. For example:
Input: /2009/5/song 01 of 3
Output: /2009/0005/song 0001 of 0003
What's the best way to do this with regular expressions?
© Stack Overflow or respective owner