# Regular Expression to Extract Album

**URL:** <https://community.mp3tag.de/t/regular-expression-to-extract-album/14790>\
**Category:** Support\
**Created:** [June 9, 2013, 5:39am UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790 "2013-06-09T05:39:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)\
**Post date:** [June 9, 2013, 5:39am UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/1 "2013-06-09T05:39:05Z")

</div>

Hope someone can help please

I am trying to clean up my album names for multi disc albums, by using the discnumber tag rather than a suffix on the album name

When i format value album with  
$regexp(%album%,(._)(disc|cd)(\D{0,3})(\d{1,2})(._),$1,1)

The Complete Singles Collection (CD 1) get turned into  
The Complete Singles Collection (

how can i move whitespace and '(' out of $1 please. NB some albums legitimately end in ')', and not all albums have discnumbers in them; The expression seems to only match the right albums and does not create false positives.

i have tried various character classes and escapings of '(' of optional existence and length prior to disc|cd but not getting anywhere.

in English I want to say $1 should be as greedy as possible but not take any non alpha character or ')' ;eg '(',\s,\_;, that might immediately (say up to 3 characters) preceed disc|cd. If there is no match then the album doesn't contain a disc number so dont do anything.

thank you

---

<div class="post-metadata">

**Author:** ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)\
**Post date:** [June 9, 2013, 6:53am UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/2 "2013-06-09T06:53:46Z")

</div>

$regexp(%album%,'\s+(?(disc|cd)\D{0,3}\d{1,2})?',,1)

---

<div class="post-metadata">

**Author:** ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)\
**Post date:** [June 9, 2013, 9:25am UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/3 "2013-06-09T09:25:46Z")

</div>

thank you very much

so what does putting the expression in '' do...allow '(' to work?  
was it significant that you removed the capturing () placeholders / $N method..or was that just a choice?

do you know how i can build out  
\s+(?

to say \s\*_( but appear in any order any number of times (to capture all possible messy album names to disk suffix 'joins')...would a chracter class work ? [\s_(]\*..

---

<div class="post-metadata">

**Author:** ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)\
**Post date:** [June 9, 2013, 10:05am UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/4 "2013-06-09T10:05:16Z")

</div>

'...' is used because some characters like ( [ have a special function in the Mp3tag scripting language. So if you make a longer expression it's just safer and more readable surround the whole term with '  
With ( ) it can work without ' but not always.

I removed the $n capturing because you just want to remove a certain part and it doesn't matter what comes before it.

[\s\_(]\* should work. You can also write [\s\_(]\*

---

<div class="post-metadata">

**Author:** ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)\
**Post date:** [June 9, 2013, 4:02pm UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/5 "2013-06-09T16:02:29Z")

</div>

thanks again

---

<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:24pm UTC](https://community.mp3tag.de/t/regular-expression-to-extract-album/14790/6 "2026-02-09T12:24:31Z")

</div>

Closed on February 9, 2026, 12:24pm UTC


