# How to add a leading zero for tracknumbers via regexp

**URL:** https://community.mp3tag.de/t/how-to-add-a-leading-zero-for-tracknumbers-via-regexp/8006
**Category:** Support
**Created:** [February 26, 2009, 3:58pm UTC](https://community.mp3tag.de/t/how-to-add-a-leading-zero-for-tracknumbers-via-regexp/8006 "2009-02-26T15:58:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zazamark](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/z/c5a1d2/32.png) [@zazamark](https://community.mp3tag.de/u/zazamark)
#### Post date: [February 26, 2009, 3:58pm UTC](https://community.mp3tag.de/t/how-to-add-a-leading-zero-for-tracknumbers-via-regexp/8006/1 "2009-02-26T15:58:51Z")

</div>

> [@Regular Expressions](https://community.mp3tag.de/t/regular-expressions/521/1):
>
> Actually, here is a single regex that does everything that I want:
> 
> Regex:
> 
> ```
> \s*0?(\d+)(\s*/\s*\d+)?\s*
> 
> ```
> 
> Replace with:
> 
> ```
> $1
> 
> ```
> 
> This will remove any trimable whitespace around the number (which will be the track tag in my case), remove any leading zero from the number, and remove any suffix after the number that starts with a '/' char (e.g. the total track count).

Very cool! How can this be changed to add a leading zero to single digit track numbers?

TIA

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [February 26, 2009, 6:07pm UTC](https://community.mp3tag.de/t/how-to-add-a-leading-zero-for-tracknumbers-via-regexp/8006/2 "2009-02-26T18:07:46Z")

</div>

Split topic from Regular exp​ressions.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:21pm UTC](https://community.mp3tag.de/t/how-to-add-a-leading-zero-for-tracknumbers-via-regexp/8006/3 "2026-02-09T12:21:24Z")

</div>


