# Replaceing / Deleting Stings with Regular Expressions

**URL:** https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142
**Category:** Support
**Created:** [March 19, 2010, 5:44pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142 "2010-03-19T17:44:02Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 19, 2010, 5:44pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/1 "2010-03-19T17:44:02Z")

</div>

Hello Everyone

I am new to the MP3TAG forum. Greets! I have what I am sure is a simple question but for the life of me I have been unable to find an answer. I just cant get my head around regular expressions as implemented in MP3TAG. I have read many posts and have not found a clear answer to this question.

I have a bunch of MP3's in the format of - .mp3 for example,  
an MP3 named Bob James - Reunited.mp3. I would like the title to end up being just  
Reunited.mp3. I would like to DELETE or REMOVE all characters starting from the beginning of the string up to the first "-". I cannot figure out how to do such a simple thing.

I would also like to know how to do the opposite, by that I mean I would like to be able to search for the first instance of "-" and REMOVE or DELETE all text AFTER that instance to the end of the string.

If anyone could help me out with EITHER expression it would be GREATLY appreciated. I have been missing around with this for over a month ( it was a personal challenge 🙂 but I just cannot get it to work.

I am using MP3TAG v 2.46

Any response is greatly Appreciated.

DrWho

---

<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: [March 19, 2010, 6:33pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/2 "2010-03-19T18:33:40Z")

</div>

> [@DrWho](#):
>
> ... I have a bunch of MP3's in the format of - .mp3 ... I would like the title to end up being just Reunited.mp3. ...

Your request sounds similar to this thread ...  
[/t/10138/1](https://community.mp3tag.de/t/10138/1)

DD.20100319.2033.CET

---

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 19, 2010, 6:55pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/3 "2010-03-19T18:55:48Z")

</div>

Yes it is very similar. And I see he never got an answer either 🙂

IS there a simple solution to this question?

---

<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: [March 19, 2010, 7:58pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/4 "2010-03-19T19:58:07Z")

</div>

I take it that you are somewhat allergic to regular expressions.  
So if your filename looks like - .mp3  
you can easily rewrite your tags by importing the right section with the function filename - tag:  
The mask looks lke this:  
%artist% - %title%  
The preview should re-ensure you to get the right result.  
If you still want a solution with regular expressions you have to come back to this thread.

---

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 20, 2010, 1:53am UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/5 "2010-03-20T01:53:48Z")

</div>

Thank you for your reply Ohrenkino. Yes for the moment I am 'allergic' to RE's. I would really like to learn tho. This could be a very useful tool if I could figure it out. I am more than willing to give it a try tho. I just need a bit of guidance 🙂 To explain further, my MP3's, have NO OTHER ID3 TAG Information other than TITLE and ARTIST information. Everything else is blank.

For Example:

ID3 Tag Artist: Groovy Music  
ID3 Tag Title: Bob James - Reunited

So I would like to start arranging the ID3 tag information so I can use CDDB or somthing similar to fill-in in as much ID3 information as possible. So next I replaced the ARTIST tag with the TITLE tag. Now my ID3 information looks like this ....

ID3 Tag Artist: Bob James - Reunited  
ID3 Tag Title: Bob James - Reunited

Next I would like to fix the information in the ID3 tag fields. I would like to remove 'Bob James -' from the Artist field and I would like to remove '- reunited' from the Title Tag so that it would end up like so

ID3 Tag Artist: Bob James  
ID3 Tag Title: Reunited

IDEALLY I would like to fill in the TITLE tag from the Filename information but that is another topic. I hope this is a bit more clear.

Ohrekino Thank you for your replay but I do not understand what you are saying. Where would I APPLY this MASK? It would appear that mask will just reverse the TITLE and ARTIST tags. That is not quite what I am trying to do ....

Thank you for your reply!

---

<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: [March 20, 2010, 6:44am UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/6 "2010-03-20T06:44:14Z")

</div>

> [@DrWho](#):
>
> Yes it is very similar. And I see he never got an answer either 🙂 IS there a simple solution to this question?

Sure, there are answers, even to your problem situation.  
[Renaming/Removing Items From Tags](https://community.mp3tag.de/t/10138/4)

DD.20100320.0844.CET

---

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 20, 2010, 11:58am UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/7 "2010-03-20T11:58:30Z")

</div>

Thank you for your reply DetLevD. Can you perhaps tell me how to do what you are suggesting? At least tell me where the menu options are? I apolgize for being a Noob and asking questions but everyone must start somewhere. I did not create this software and I am not intimately familiar with every menu option and it's use.

Thank you for your reply.

---

<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: [March 20, 2010, 12:09pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/8 "2010-03-20T12:09:44Z")

</div>

> [@DrWho](#):
>
> ... everyone must start somewhere. ...

Yes, you are right, so start Mp3tag, load and select a test file and browse through the menus, look around what is offered to you, learn the names of menu items and what the items will do. Read the help manual.

From my side it is all said how to use Mp3tag in the given cases and where to find the functionality in Mp3tag, which I have described how to use.

DD.20100310.1410.CET

---

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 20, 2010, 12:15pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/9 "2010-03-20T12:15:07Z")

</div>

I have tried what you referred me to in the previous post. It appears as if this will change the actual FILENAME. I am not interested in changing the FILENAME but the ID3 tag fields. I wopuld like to change the Artist and Title. If I do this as mentiond to try

Supposing that the tag fields ARTIST and TITLE are empty or do contain erasable informations, and the filename contains the information for setting the tag fields ARTIST and TITLE, then you can use Mp3tag/Convert/Filename-Tag.

With a given filename of "artist - title.mp3", where "artist" stands for the textual information about the artist and "title" stands for the textual information about the title, both parts separated by a literal string of ' - ', which is unique to the both informations parts, then you can use the following format string (or mask) to fill the tag fields automatically with the related content from the filename:  
%ARTIST%' - '%TITLE%

And PREVIEW the results, the results show I am changing the FILENAME. I do not wish to change the FILENAME. I want to change ID3 TAG informations. At least it appears to me.

---

<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: [March 20, 2010, 12:50pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/10 "2010-03-20T12:50:28Z")

</div>

It is not clear to what text passage of the offered solutions you reply now.

Please use the quoting function of this forum board when you are quoting passages from other user's posting.

> [@DrWho](#):
>
> ...  
> I have tried what you referred me to in the previous post. It appears as if this will change the actual FILENAME. I am not interested in changing the FILENAME but the ID3 tag fields. ...

Well, then change the tag fields.  
I have all layed out what Mp3tag beginners can easily use.  
"Filename-Tag" and "Tag-Filename" should help perfectly in your situation.

When you have learned to work with these both beginner dialogs in an error free manner, then we can speak about using Mp3tag scripting functions and even about using of Regular Expressions in order to do the same tasks another way but not simpler at all.

> [@DrWho](#):
>
> ...  
> And PREVIEW the results, the results show I am changing the FILENAME. I do not wish to change the FILENAME. I want to change ID3 TAG informations. At least it appears to me. ...

What you say is not correct.  
The dialog "Filename-Tag" offers a "Preview", which shows the content of the tag fields in question (which could be detected and broken down by the given format string), how they will be physically filled when the process "Filename-Tag" has been accepted.

DD.20100320.1458.CET

---

<div class="post-metadata">

### Author: ![DrWho](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@DrWho](https://community.mp3tag.de/u/DrWho)
#### Post date: [March 20, 2010, 1:01pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/11 "2010-03-20T13:01:20Z")

</div>

Never mind then. I just dont understand forums like these. You put them here so people can ask for help with software that you have taken the time and trouble to produce and then get mad when people ask legitimate questions I am not in ANY WAY trying to say or imply anything BAD about your software. You have NO NEED to be SO DEFENSIVE. I am simply asking a question about how to use your software in a way I cannot figure out.

Sorry to have wasted your time, it would appear this software cannot perform this SIMPLE task.

Thank you for your support

---

<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: [March 20, 2010, 1:19pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/12 "2010-03-20T13:19:46Z")

</div>

> [@DrWho](#):
>
> ... I am simply asking a question about how to use your software in a way I cannot figure out. ...

There might be another way too to help you over the hurdle.

Create a group of actions ...

Begin Actionsgroup **Test#20100320.DrWho**

Action #1  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%ARTIST%**  
_Guessing pattern:_ **%ARTIST%÷-÷%DUMMY%**

Action #2  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%TITLE%**  
_Guessing pattern:_ **%DUMMY%÷-÷%TITLE%**

_Note: Replace each special ÷ character with one space character._  
End Actionsgroup **Test#20100320.DrWho** (2 Actions)

... and run it against your files which follows your example from above, i. e.  
ARTIST = "Bob James - Reunited"  
TITLE = "Bob James - Reunited"

The result will be ...  
ARTIST = "Bob James"  
TITLE = "Reunited"

A last advice:  
Read the help manual.  
Read through this forum and learn from the questions of other users.  
Try out the Mp3tag world for yourself.

DD.20100320.1519.CET

---

<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: [March 20, 2010, 4:02pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/13 "2010-03-20T16:02:05Z")

</div>

> [@DrWho](#):
>
> ... you can use the following format string (or mask) to fill the tag fields automatically with the related content from the filename:  
> %ARTIST%' - '%TITLE% ...

The previously quoted message shows, that an error can happen even in the moment when someone will do it perfectly.

The formatstring _%ARTIST%' - '%TITLE%_ is bad.  
The formatstring _%ARTIST% - %TITLE%_ is good.

I apologize for the despair while my proposal has not worked as desired.

DD.20100320.1801.CET

---

<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: [March 21, 2010, 6:42am UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/14 "2010-03-21T06:42:03Z")

</div>

> [@DetlevD](#):
>
> ... run it against your files which follows your example from above, i. e.  
> ARTIST = "Bob James - Reunited"  
> TITLE = "Bob James - Reunited"  
> ...

If someone will go the Mp3tag scripting way, then the following scripting strings, used together with **Action "Format value"** , will give the same results as the "Guessing values" actions from above post #12.

From:  
ARTIST = "Bob James - Reunited"  
To:  
ARTIST = "Bob James"  
$left(%ARTIST%,$sub($strstr(%ARTIST%,' - '),1))

From:  
TITLE = "Bob James - Reunited"  
To:  
TITLE = "Reunited"  
$right(%TITLE%,$sub($len(%TITLE%),$strstr(%TITLE%,' - '),2))

DD.20100321.0840.CET

Using the scripting function **$regexp()** together with **Action "Format value"** looks like following:

From:  
ARTIST = "Bob James - Reunited"  
To:  
ARTIST = "Bob James"  
$regexp(%ARTIST%,'^(.+?)\s-\s.+?$',$1)

From:  
TITLE = "Bob James - Reunited"  
To:  
TITLE = "Reunited"  
$regexp(%TITLE%,'^.+?\s-\s(.+?)$',$1)

DD.20100321.0848.CET

Using **Action "Replace with Regular Expression"** looks like following:

Begin Actionsgroup **Test#20100320.DrWho (1)**

Action #1  
_Actiontype 4:_ **Replace with regular expression**  
_Field:_ **ARTIST**  
_Regular expression:_ **^(.+?)\s-\s.+?$**  
_Replace matches with:_ **$1**

[\_] Case sensitive comparison

Action #2  
_Actiontype 4:_ **Replace with regular expression**  
_Field:_ **TITLE**  
_Regular expression:_ **^.+?\s-\s(.+?)$**  
_Replace matches with:_ **$1**

[\_] Case sensitive comparison

End Actionsgroup **Test#20100320.DrWho (1)** (2 Actions)

DD.20100321.0855.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:22pm UTC](https://community.mp3tag.de/t/replaceing-deleting-stings-with-regular-expressions/10142/15 "2026-02-09T12:22:15Z")

</div>


