# help with regex to remove parts of the title

**URL:** https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879
**Category:** Support
**Created:** [December 30, 2011, 7:12am UTC](https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879 "2011-12-30T07:12:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![666JTK666](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/6/ba9def/32.png) [@666JTK666](https://community.mp3tag.de/u/666JTK666)
#### Post date: [December 30, 2011, 7:12am UTC](https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879/1 "2011-12-30T07:12:13Z")

</div>

hi folks I would apreciate a little help.

ok i have a bunch of mp3's whith the title tag like this.

001 - nameofsong - album example 001 - bozo - bozo's greatest hits

I want to get rid of the track# and the album thus my title would be only bozo

I have poked around a bit and found this  
^\s\*[0-9]+\s\*-\s\*  
and it seems to work good at removing the track number.  
But I am at a loss on how to remove everything from the end of the songname forwards.

big ty for your help.

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [December 31, 2011, 3:45pm UTC](https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879/2 "2011-12-31T15:45:51Z")

</div>

> [@666JTK666](#):
>
> 001 - nameofsong - album example 001 - bozo - bozo's greatest hits
> 
> I want to get rid of the track# and the album thus my title would be only bozo.

use.  
reg exp: \[1\]\s+-\s+[^-]\s+-\s+[^-]\s+-\s+([^-])\s+-\s+[^-]$  
replace with: $1

^ anchors search to beginning of text string.  
[^-] finds everything which is NOT a '-'.  
\s+ \s finds whitespace and + is a limiter which finds an unlimited amount of whitespaces.  
- finds the '-' character.  
It carrys on the pattern with 5 [^-] and 4 \s+-\s+ like the pattern you have.  
$ anchors search at end of text string.

_EDIT_  
notice the surrounding brackets ([^-]) on the 4th [^-] in the reg exp.  
The function for this it to capture the text string contained inside that. That is why the return is $1.  
If you had another capture in the reg exp the value for that would be $2 and so on. BTW captures work from left to right.  
Hope this helps.

* * *

1. ^-

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [December 31, 2011, 6:29pm UTC](https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879/3 "2011-12-31T18:29:04Z")

</div>

> [@666JTK666](#):
>
> ... mp3's whith the title tag like this.  
> 001 - nameofsong - album example 001 - bozo - bozo's greatest hits  
> I want to get rid of the track# and the album thus my title would be only bozo ...

You are in luck, the TITLE tag-field's content is a 'well formed' string, which can be easily divided into single items, because of the embedded space-hyphen-space character sequence separators.

When using the Regular Expression language, a possible solution looks like this ...  
$regexp(%TITLE%,'^(.+?) - (.+?) - (.+?) - (.+?) - (.+?)$','$4')  
... will return the fourth item.

$regexp(%TITLE%,'^(.+?) - (.+?) - (.+?) - (.+?) - (.+?)$','$4 - $5')  
... will return the fourth and fifth item, separated by a space-hyphen-space character sequence.

As an alternative you can use ...  
Action: "Guess values"  
Source format: %TITLE%  
Guessing pattern: %DUMMY% - %DUMMY% - %DUMMY% - %TITLE% - %DUMMY%  
... will save the fourth item into the tag-field TITLE.

Guessing pattern: %DUMMY% - %DUMMY% - %DUMMY% - %TITLE%  
... will save the fourth and fifth item into the tag-field TITLE.

Guessing pattern: %DUMMY% - %TITLE% - %DUMMY%  
... will save the second item into the tag-field TITLE.

DD.20111231.2030.CET

---

<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:23pm UTC](https://community.mp3tag.de/t/help-with-regex-to-remove-parts-of-the-title/12879/4 "2026-02-09T12:23:33Z")

</div>


