# Please help with another special regular expression

**URL:** https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938
**Category:** Support
**Created:** [October 13, 2010, 8:12am UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938 "2010-10-13T08:12:04Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![globetrotters1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@globetrotters1](https://community.mp3tag.de/u/globetrotters1)
#### Post date: [October 13, 2010, 8:12am UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/1 "2010-10-13T08:12:04Z")

</div>

Well, thanks for the help with the "in" before Dur/moll, just works perfectly the way you told me...

There are two problems left, one of which I think you can solve, the other will be unsolvable.

**Problem 1:**

Some track names I get from Amazon or freedb have "in B" **at the end** of the filename, just before the file extension. I want to catch those and replace them with "in H-Dur" (if capital B of course). otherwise to "in h-moll". I could solve all cases in which this expression shows up somewhere else in the filename, just the end of line case is a problem.

I want to **exclude** the cases in which it already has a Dur or moll signature.

Additionally it should also replace "in B flat" to "in B-Dur" and "in fis sharp" to "in fis-moll". So also the expressions "flat/bemol" and "sharp/#/diese/dièse/diesis/sostenido" should be honored correctly. Then all common key signature languages (eng/fra/ita/esp) are included. I think the simplest way would be to first replace all these special ending values into "flat" or "sharp" and then process one expression which does the formatting of the value

**Problem 2 (which I think is unsolvable):**

The formatting I receive from Amazon or freedb looks like this  
**01 - String Quartet No 14 in d-moll, D 810 - Allegro**  
**02 - String Quartet No 14 in d-moll, D 810 - Andante con moto**  
**03 - String Quartet No 14 in d-moll, D 810 - Scherzo: Allegro molto**  
**04 - String Quartet No 14 in d-moll, D 810 - Presto**  
and I would like to have it like this  
**01 - String Quartet No 14 in d-moll, D 810 - I - Allegro**  
**02 - String Quartet No 14 in d-moll, D 810 - II - Andante con moto**  
**03 - String Quartet No 14 in d-moll, D 810 - III - Scherzo: Allegro molto**  
**04 - String Quartet No 14 in d-moll, D 810 - IV - Presto**

That would mean that I can do a roman number sequencing action in consecutive tracks I highlight. Until now I have to do all this manually, which is very time consuming 🙂

And to make it even more difficult, it would be very cool to be able to solve "elimination of same string elements from second occurrence on", so that it looks like this  
**01 - String Quartet No 14 in d-moll, D 810 - I - Allegro**  
**02 - II - Andante con moto**  
**03 - III - Scherzo: Allegro molto**  
**04 - IV - Presto**

Appreciate your help!  
Thanks  
😆

---

<div class="post-metadata">

### Author: ![globetrotters1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@globetrotters1](https://community.mp3tag.de/u/globetrotters1)
#### Post date: [October 24, 2010, 2:12pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/2 "2010-10-24T14:12:14Z")

</div>

where are the 'Regular Expression Geeks', who can help??  
🙂

---

<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: [October 24, 2010, 3:35pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/3 "2010-10-24T15:35:22Z")

</div>

> [@globetrotters1](#):
>
> where are the 'Regular Expression Geeks', who can help??🙂

A club-mate always says, if you are looking for a helping hand, then look at the end of your arm.

Regex: Roman numerals in uppercase  
[Regular Expressions](https://community.mp3tag.de/t/521/32)

Converting roman to arabic number and vice versa, - implemented as action groups -  
[Converting roman to arabic number and vice versa](https://community.mp3tag.de/t/4565/1)

All music related knowledge stuff is up to you.  
G flat = Ges  
G sharp = Gis  
English B = German H  
[http://en.wikipedia.org/wiki/Note](http://en.wikipedia.org/wiki/Note)

"Elimination of same string elements on repeated occurrences"  
This might be possible by tricky usage of Mp3tag export scripting language, but never did it before, so the current status of this wish will be "impossible" further on.

DD.20101024.1935.CEST

---

<div class="post-metadata">

### Author: ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)
#### Post date: [October 24, 2010, 7:20pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/4 "2010-10-24T19:20:05Z")

</div>

> [@globetrotters1](#):
>
> **Problem 2 (which I think is unsolvable):**
> 
> The formatting I receive from Amazon or freedb looks like this  
> **01 - String Quartet No 14 in d-moll, D 810 - Allegro**  
> **02 - String Quartet No 14 in d-moll, D 810 - Andante con moto**  
> **03 - String Quartet No 14 in d-moll, D 810 - Scherzo: Allegro molto**  
> **04 - String Quartet No 14 in d-moll, D 810 - Presto**  
> and I would like to have it like this  
> **01 - String Quartet No 14 in d-moll, D 810 - I - Allegro**  
> **02 - String Quartet No 14 in d-moll, D 810 - II - Andante con moto**  
> **03 - String Quartet No 14 in d-moll, D 810 - III - Scherzo: Allegro molto**  
> **04 - String Quartet No 14 in d-moll, D 810 - IV - Presto**
> 
> That would mean that I can do a roman number sequencing action in consecutive tracks I highlight. Until now I have to do all this manually, which is very time consuming 🙂
> 
> And to make it even more difficult, it would be very cool to be able to solve "elimination of same string elements from second occurrence on", so that it looks like this  
> **01 - String Quartet No 14 in d-moll, D 810 - I - Allegro**  
> **02 - II - Andante con moto**  
> **03 - III - Scherzo: Allegro molto**  
> **04 - IV - Presto**
> 
> Appreciate your help!  
> Thanks  
> 😆

Actiongroup:

1. Format Value:  
Field:  
TITLE  
Format String:  
$regexp(%title%,(._?) - (._?) - (._),$1) - $if($eql($left(%title%,2),01),$regexp(%title%,(._?) - (._?) - (._),$2 - $1),$regexp(%title%,(._?) - (._?) - (._),$1)) - $regexp(%title%,(._?) - (._?) - (._),$3)

2. Replace with regular expression:  
Field:  
TITLE  
Regular Expression:

- (\d\d) -  
Replace matches with:
- $replace($1,01,I,02,II,03,III,04,IV,05,V,06,VI,07,VII,08,VIII,09,IX,10,X) -

works for roman numbers I-X, but you can append as many numbers as you need in the last string.

EDIT:  
Problem 1 sounds simple:  
Include for every every key-signature which sould be changed something like this:

Action: Replace  
Field: TITLE  
Original: in B  
Replace with: in H-Dur

will be a lot of work for 4 different languages and the different key signatures.

---

<div class="post-metadata">

### Author: ![globetrotters1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@globetrotters1](https://community.mp3tag.de/u/globetrotters1)
#### Post date: [October 28, 2010, 2:58pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/5 "2010-10-28T14:58:06Z")

</div>

> [@pone](#):
>
> ...  
> Problem 1 sounds simple:  
> Include for every every key-signature which sould be changed something like this:
> 
> Action: Replace  
> Field: TITLE  
> Original: in B  
> Replace with: in H-Dur
> 
> will be a lot of work for 4 different languages and the different key signatures.

Thanks for your hints... but...

It's not that simple...

It's just the "end of line" situation which is tricky. Within a title value I wrote different replacement actions (for every different language and also for the short values)

The problem is that I don't want to make out of  
**performed in Bratislava**  
a  
**performed in H-Durratislava**

Wouldn't make much sense

So for the short signatures I check "in B " (with a space) or "in B," and replace it with H-Dur

The end of line situation is the problem... (before the file extension)

I want to check if the string terminates with "in X" (X can be 1-3 characters wide) and if X begins with a capital letter then add a " major", with a lower case character a " minor"

Then I can replace with my english to german action easily  
🙂

---

<div class="post-metadata">

### Author: ![globetrotters1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@globetrotters1](https://community.mp3tag.de/u/globetrotters1)
#### Post date: [October 28, 2010, 3:00pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/6 "2010-10-28T15:00:46Z")

</div>

And thanks for your suggestion of the numbering problem...

It doesn't work

Because it just works if the track numbers are 01 to 04... but what if the tracks of these four movements are 07 to 11?

Anyway, I thought it will be not to solve  
But thanks for the nice hint 🙂

The only way to solve this problem would be if you could refer to the previous track title and depending on the roman number you set there you would set the next roman number in the actual line value... hope that this was understandable, lol

---

<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: [October 28, 2010, 3:31pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/7 "2010-10-28T15:31:34Z")

</div>

> [@globetrotters1](#):
>
> ... I want to check if the string terminates with "in X" (X can be 1-3 characters wide) ...

A filter string could look like this (case sensitive):

**"%\_FILENAME%" MATCHES "(?-i)in (Ces|Ges|Des|As|Es|B|F|C|G|D|A|E|H|Fis|Cis|as|es|b|f|c|g|d|a|e|h|fis|cis|gis|dis**

**|ais)$"**

 

A filter string could look like this (case insensitive):

 **"%\_FILENAME%" MATCHES "in (a|ais|as|b|c|ces|cis|d|des|dis|e|es|f|fis|g|ges|gis|h)$"** 

A filter string could look like this (case insensitive):

 **"%\_FILENAME%" MATCHES "in (((c|d|g)((e|i)s)?)|(a(is|s)?)|(es?)|(f(is)?)|b|h)$"** 

Testfiles:  
[20110104.Test.Tonarten.zip](https://community.mp3tag.de/uploads/default/original/2X/3/321620bdec9313be74398e3c8c750728bb9d5365.zip) (6.84 KB)

 

DD.20101028.1931.CEST  
Edit.DD.20110104.1552.CET

 

[20110104.Test.Tonarten.zip](https://community.mp3tag.de/uploads/default/original/2X/3/321620bdec9313be74398e3c8c750728bb9d5365.zip) (6.84 KB)

---

<div class="post-metadata">

### Author: ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)
#### Post date: [October 28, 2010, 5:56pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/8 "2010-10-28T17:56:57Z")

</div>

> [@globetrotters1](#):
>
> And thanks for your suggestion of the numbering problem...
> 
> It doesn't work
> 
> Because it just works if the track numbers are 01 to 04... but what if the tracks of these four movements are 07 to 11?
> 
> Anyway, I thought it will be not to solve  
> But thanks for the nice hint 🙂
> 
> The only way to solve this problem would be if you could refer to the previous track title and depending on the roman number you set there you would set the next roman number in the actual line value... hope that this was understandable, lol

Ah, ok, I thought Roman I always coresponds to Arabic 1. I'll think about it.

---

<div class="post-metadata">

### Author: ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)
#### Post date: [October 28, 2010, 11:14pm UTC](https://community.mp3tag.de/t/please-help-with-another-special-regular-expression/10938/9 "2010-10-28T23:14:53Z")

</div>

Problem 1:

> [@globetrotters1](#):
>
> So for the short signatures I check "in B " (with a space) or "in B," and replace it with H-Dur
> 
> The end of line situation is the problem... (before the file extension)

$ matches the end of a line, so check for "in B$"  
you can also check for alternatives with "|". this would be perfect for you:

$regexp(%title%,in B($| |','),in H-Dur$1)

Problem 2:  
Format the Title with this string:  
$regexp(%title%,(._?) - (._?) - (.\*),$1 - $if($eql(%\_counter%,1),$2 - I,$replace(%\_counter%,1,I,2,II,3,III,4,IV,5,V,6,VI,7,VII,8,VIII,9,IX,10,X)) - $3)

BUT: You can't format the whole album at one go. You have to do it separately for every Roman number sequence.

---

<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/please-help-with-another-special-regular-expression/10938/10 "2026-02-09T12:22:36Z")

</div>


