# Padding numbers in sort fields

**URL:** https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949
**Category:** Support
**Created:** [February 21, 2010, 5:11pm UTC](https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949 "2010-02-21T17:11:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JamieF](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/e495f1/32.png) [@JamieF](https://community.mp3tag.de/u/JamieF)
#### Post date: [February 21, 2010, 5:11pm UTC](https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949/1 "2010-02-21T17:11:06Z")

</div>

Hi

Is there a way to pad the first number that appears (anywhere) in a field?

e.g. "Symphony No. 1 in E minor" \> "Symphony No. 001 in E minor"

I know how to find the number using regex, but I can't work out a way of padding it (say to three digits) if I don't know how many digits it was in the first place. This problem appears to be a mix of regex (to find the number) and formatting $num(x,y) to pad it.

Any ideas?

Thanks

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 21, 2010, 5:46pm UTC](https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949/2 "2010-02-21T17:46:55Z")

</div>

> [@JamieF](#):
>
> This problem appears to be a mix of regex (to find the number) and formatting $num(x,y) to pad it.
> 
> Any ideas?
> 
> Thanks

I Think if you separate the search into several bits it might be less horrifying:

A search string like "Symphony No. 001 in E minor" can be divided into 3 sections:  
the string in front of the number, ths number and the string behind the number.

Searching for such a thing would be:  
(.\* )(\d+)( .\*)  
separates the search into  
(%1)(%2)(%3) where you can read the % as "part".

replacing it would look something like this:  
%1$num(%2,y)%3

This is the basic idea. try it first whether it works

---

<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 21, 2010, 6:39pm UTC](https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949/3 "2010-02-21T18:39:32Z")

</div>

Placeholders for groups in regular expressions are denoted using the dollar sign (e.g., $1 for the first group, $2 for the second group, and so on).

You can try an action **Replace with regular expression**  
_Field:_ **YOURSORTFIELD**  
_Regular expression:_ **(._)(\d+)(._)**  
_Replace matches with:_ **$1$num($2,3)$3**

---

<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:22pm UTC](https://community.mp3tag.de/t/padding-numbers-in-sort-fields/9949/4 "2026-02-09T12:22:12Z")

</div>


