# Last number in %album% to become %discnumber% using regular expression

**URL:** https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312
**Category:** Support
**Created:** [June 15, 2020, 9:07am UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312 "2020-06-15T09:07:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dev91618](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dev91618](https://community.mp3tag.de/u/dev91618)
#### Post date: [June 15, 2020, 9:07am UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312/1 "2020-06-15T09:07:24Z")

</div>

Hello, greetings all.

I want to use regular expression  
(\d+)(?!.\*\d)  
to extract the last number in %album% and apply that as %discnumber%.

I want to create it as a part of action group.

I am currently using $right(%album%,1) method, but want to create a more general method using regular expressions.

But with regular expressions, I can't get around achieving this using $regexp, $format, or $replace

I also thought vaguley about using $if or $if2 as a hack to achieve it but no success since yesterday.

Any suggestions will be helpful. Thanks in deed, and good day.

---

<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: [June 15, 2020, 9:12am UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312/2 "2020-06-15T09:12:47Z")

</div>

this thread is in German but you will see that the problem of getting a number from the end of TITLE into YEAR is very similar to getting a number from the end of ALBUM into DISCNUMBER:

> [@Wie kann ich Jahr aus einem Titel in YEAR einfügen?](https://community.mp3tag.de/t/wie-kann-ich-ein-jahrgang-aus-einen-titel-in-jahrgang-einfugen/49296):
>
> Hallo Ihr Lieben Könnts ihr mir Bitte Helfen Und zwar habe ich mehrere Songs und zwar so: Interpret - Titel Jahrgang hier möchte aber das das Jahrgang im Titel bleibt aber auch in der Katekorie Jahrgang drinnen steht. (Siehe Foto) Wie muss ich das machen sag da mal ganz Lieb Danke für euere Hilfe slightly_smiling_face

---

<div class="post-metadata">

### Author: ![dev91618](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dev91618](https://community.mp3tag.de/u/dev91618)
#### Post date: [June 15, 2020, 4:39pm UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312/4 "2020-06-15T16:39:57Z")

</div>

Hello and thanks. I understand that $1 should do the trick. There is some progress, and I have tested the regular expression formula, but I am not getting the intended result.  
Album name without quotes: 'Dance Vol. 10 ABC'  
format discnumber  
$regexp(%album%,(\d+)(?!.\*\d),$1)  
leads to discnumber as  
Dance Vol. 10 ABC  
instead of the expected and intended  
10

Thank you for your further help in the matter. I also will play around more and report.

---

<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: [June 15, 2020, 5:04pm UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312/5 "2020-06-15T17:04:44Z")

</div>

> [@dev91618](#):
>
> Dance Vol. 10 ABC

Yes, because it does not match the pattern that you described in

> [@dev91618](#):
>
> `(\d+)(?!.*\d)`

That pattern reads: a number followed by any string followed by a number.  
But  
`Dance Vol. 10 ABC`  
is: any string, a number, any string. it does not even have the number at the end.  
If a regular expression does not find a match, it returns the source string.  
Also, I wonder which results you got when you referenced $1 instead of $2 which is actually the number at the end of the string.  
Please note that the linked thread uses  
`$regexp(%title%,.*(\d\d\d\d),$1)`  
If you do not have 4-digit numbers at the end, then use  
`$regexp(%title%,.*(\d\+),$1)`  
Still, this does not cater for

> [@dev91618](#):
>
> Dance Vol. 10 ABC

which would be  
`$regexp(%title%,.*Vol. (\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 9, 2026, 12:28pm UTC](https://community.mp3tag.de/t/last-number-in-album-to-become-discnumber-using-regular-expression/49312/6 "2026-02-09T12:28:39Z")

</div>


