# Regexp Regular Expression to get number

**URL:** https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587
**Category:** Support
**Created:** [January 26, 2026, 12:57pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587 "2026-01-26T12:57:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![M4ster3](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@M4ster3](https://community.mp3tag.de/u/M4ster3)
#### Post date: [January 26, 2026, 12:57pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/1 "2026-01-26T12:57:16Z")

</div>

Hi there,

i start this with beeing plain honest, i tried now several hours with some ChatGPT help to get this Regexp to work, but it doesn´t, so may some of you explain to a noob why this is not working in any way.

Case:

I have a huge amount of files which are particialy grouped, where the Tags in album are the same for every group.

Episode 1: Word Word

Episode 1: Word Word (←—basicaly antoher part of the whole audio group Episode 1)

Episode 2: AnotherWord Word

Episode 2: AnotherWord Word (←—basicaly antoher part of the whole audio group Episode 2)

and so on.

So now i try to extract ONLY the number to copy it to the tag “series-part”.

Chatgpt gave me this expression which i added to an action and there into tag-forma, $regexp(%album%,Episode ([0-9]+),$1) but i always end up with “Redexp Error: Regular Expression” .

Can someone explain to why this fails?

Sorry for my english and greetings from Germany

---

<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: [January 26, 2026, 1:02pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/2 "2026-01-26T13:02:09Z")

</div>

as in regular expression each character matters to define the pattern, a real example would be helpful.  
To get a number try `\d`, e.g  
Convert\>Tag-Tag for "series part"  
Format string: `$regexp(%album%,.*(\d+).*,$1)`

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 26, 2026, 1:38pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/3 "2026-01-26T13:38:46Z")

</div>

> [@M4ster3](#):
>
> $regexp(%album%,Episode ([0-9]+),$1) but i always end up with “Redexp Error: Regular Expression” .
> 
> Can someone explain to why this fails?

It fails, because the square brackets `[` and `]` are special characters in a regular expression. They have to be "escaped". In your case, you can enclose it in Mp3tag with `'` to look like this:  
`$regexp(%album%,Episode ('[0-9]'+),$1)`  
**(I have not checked if this expression works as expected!**  
It's just the explanation for the error message:  
 ![image](https://community.mp3tag.de/uploads/default/original/3X/7/7/77f0739e17086a4ed4ce4ed73a2a9fe73349cbb9.png)  
)

Update:  
One way to use your regular expression to only get the number 2 in your example would be:  
`$regexp(%album%,Episode ('[0-9]+'):.+,$1)`

 ![image](https://community.mp3tag.de/uploads/default/original/3X/4/4/4465032e9677c23a31f158ebc6054bbcdd495502.png)

This only works if you leave a space between the word **Episode** and your digit(s). Then a colon has to follow and then any other character.

> [@M4ster3](#):
>
> Sorry for my english and greetings from Germany

Kein Problem. Wenn es Dir lieber ist, kannst Du auch den deutschsprachigen Teil dieses Forums verwenden: #Deutsch / German

---

<div class="post-metadata">

### Author: ![M4ster3](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@M4ster3](https://community.mp3tag.de/u/M4ster3)
#### Post date: [January 26, 2026, 2:39pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/4 "2026-01-26T14:39:48Z")

</div>

Thanks guys for the fast reply, really appriciate it.

> [@ohrenkino](#):
>
> Format string: `$regexp(%album%,.*(\d+).*,$1)`

In my particular case it works as intended for the first 9, but only as long as there is no second digit and no twodigit number - it fails in two cases:

Episode 10: Word Word Word —–\> Ends in a 0

Episode 5: Word Word Word (Part1) —→ Ends in a 1

Luckily the second case doesn´t apply this time, as there are only digits infront of the dash, but the twodigit problem stays.

> [@LyricsLover](#):
>
> $regexp(%album%,Episode ('[0-9]'+),$1)

Just for protocoll this ends in (example) “1: Word Word Word” - so it copies the text also.

* * *

* * *

> [@LyricsLover](#):
>
> $regexp(%album%,Episode ('[0-9]+'):.+,$1)

This works flawlessly with my case, it also even works (especialy tested it) with the second digit at the end (if there would be something like “Part 1” or such a thing)

A BIG THANKS! 👍

* * *

> [@LyricsLover](#):
>
> Kein Problem. Wenn es Dir lieber ist, kannst Du auch den deutschsprachigen Teil dieses Forums verwenden: #Deutsch / German

I´d like to ask such questions in english, as most of the germans speak english, but it would be a different story the other way around - so this way everyone can profit from this thread maybe…

---

<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: [January 26, 2026, 3:14pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/5 "2026-01-26T15:14:57Z")

</div>

> [@M4ster3](#):
>
> In my particular case it works as intended for the first 9, but only as long as there is no second digit and no twodigit number - it fails in two cases:

That is why I asked to get a real example. Your first examples only had single digits and no digits somewhere in the string.  
Try this: `$regexp(%album%,.*?(\d+).*,$1)`

---

<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 25, 2026, 3:15pm UTC](https://community.mp3tag.de/t/regexp-regular-expression-to-get-number/70587/6 "2026-02-25T15:15:51Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
