# Regular Expressions

**URL:** https://community.mp3tag.de/t/regular-expressions/521
**Category:** Howto
**Created:** [October 16, 2003, 4:47pm UTC](https://community.mp3tag.de/t/regular-expressions/521 "2003-10-16T16:47:29Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![captainmidnight](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@captainmidnight](https://community.mp3tag.de/u/captainmidnight)
#### Post date: [December 5, 2008, 2:56am UTC](https://community.mp3tag.de/t/regular-expressions/521/21 "2008-12-05T02:56:01Z")

</div>

I dislike it when a leading zero appears in the track number of the track tag (or when the total track count is added after a '/' char).

[Aside: It seems like a bad idea to pollute a nice simple tag like the track with extra information like this. My intuition is that the information in each tag should be kept as simple and pure as possible. In databases there is a similar concept: you usually want to achieve what is called a normalized design. But if someone has a good reason for doing otherwise, please educate me!

Note that I only have a problem with leading zeroes in the track TAGS. In contrast, when I use tracks in filenames, I DO like a leading zero if there are \> 9 tracks on the CD because that causes the filenames to be lexicographically ordered, which is critical for proper sorting by your file system, as well as it visually looks better when filenames are displayed in a list.]

Earlier in this thread, phoenixdarkdirk pointed out how to remove any '/' char and following digits.

Here is how to remove any leading zeroes (as well as trimmable whitespace):

Regex:

```
\s*0(\d+)\s*

```

Replace with:  
$1

---

<div class="post-metadata">

### Author: ![captainmidnight](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@captainmidnight](https://community.mp3tag.de/u/captainmidnight)
#### Post date: [December 5, 2008, 3:17am UTC](https://community.mp3tag.de/t/regular-expressions/521/22 "2008-12-05T03:17:29Z")

</div>

Actually, here is a single regex that does everything that I want:

Regex:

```
\s*0?(\d+)(\s*/\s*\d+)?\s*

```

Replace with:

```
$1

```

[/quote]

This will remove any trimable whitespace around the number (which will be the track tag in my case), remove any leading zero from the number, and remove any suffix after the number that starts with a '/' char (e.g. the total track count).

---

<div class="post-metadata">

### Author: ![Proteus\_3k](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/6f9a4e/32.png) [@Proteus\_3k](https://community.mp3tag.de/u/Proteus_3k)
#### Post date: [March 14, 2009, 12:59pm UTC](https://community.mp3tag.de/t/regular-expressions/521/23 "2009-03-14T12:59:37Z")

</div>

> [@Fan o blues](#):
>
> It's taken me far too long to figure it out but I've finally got it working.
> 
> To change Horne, Lena to Lena Horne or  
> Hawkins, Coleman With Manny Albam & His Orchestra to Coleman Hawkins With Manny Albam & His Orchestra  
> Field: ARTIST  
> Regular Expression: **^([\w]+),\s([\w]+)**
> 
> Replace Matches with: **$2 $1**
> 
> I hope I didn't miss the answer in here somewhere. If there's an easier or better way please feel free to help.

I've just spent a while figuring this out myself, and came on here to post it only to find someone else already has 🙂  
Mine is quite similar  
Filed: ARTIST  
RegExp: ^(.+),\s+(\w\*)  
Replace With: $2 $1

Seems to work the same

---

<div class="post-metadata">

### Author: ![Lebon14](https://community.mp3tag.de/user_avatar/community.mp3tag.de/lebon14/32/8738_2.png) [@Lebon14](https://community.mp3tag.de/u/Lebon14)
#### Post date: [November 8, 2009, 3:23am UTC](https://community.mp3tag.de/t/regular-expressions/521/24 "2009-11-08T03:23:31Z")

</div>

> [@KCE](#):
>
> Really simple but this will remove any parenthesis and its contents in any part of the string
> 
> _Example:_  
> Blah (blah1) (blah 2)  
> _Result:_  
> Blah
> 
> **Regular expression:** (.+?)
> 
> **Replace matches with:**

Thank you so much for this! You saved me a LOT of time! 😃

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [November 8, 2009, 6:43pm UTC](https://community.mp3tag.de/t/regular-expressions/521/25 "2009-11-08T18:43:41Z")

</div>

I've split some off-topic posts to Problem with Actions and Regular exp​ressions.

---

<div class="post-metadata">

### Author: ![MatthiasM](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@MatthiasM](https://community.mp3tag.de/u/MatthiasM)
#### Post date: [November 19, 2009, 8:48am UTC](https://community.mp3tag.de/t/regular-expressions/521/26 "2009-11-19T08:48:41Z")

</div>

This is not a regular expression for mp3tag, but a link to a page which contains **lots of** information about creating and using regular expressions.

In my oppinion everybody who uses regexp should have read it 😉  
**[www.regular-expressions.info](http://www.regular-expressions.info)**

kind regards,  
Matthias

---

<div class="post-metadata">

### Author: ![incifinci](https://community.mp3tag.de/user_avatar/community.mp3tag.de/incifinci/32/6526_2.png) [@incifinci](https://community.mp3tag.de/u/incifinci)
#### Post date: [February 19, 2010, 8:24am UTC](https://community.mp3tag.de/t/regular-expressions/521/27 "2010-02-19T08:24:25Z")

</div>

### Switches first and last names

> [@areve](#):
>
> Another one, that switches first and last names (for instance, Jacques Brel will become Brel, Jacques):  
> Regular Expression: ^(.+)\s(.+)$  
> Replace with: $2, $1

Thank you!  
I developed it a little.

**Variant A**  
It will not change those artists, where the conversion already done (artist has comma).  
Example: Brel, Jacques William remains Brel, Jacques William

Action: regular expression  
Field: `ARTIST`  
Regular expression: `^([^,]+)\s([^,]+)$`  
Replace with: `$2, $1`

**Variant B**  
It handles multipled for WMP artists (in format "artist1/artist2/artist3"), possible nicknames at the end in square brackets and trims unnecessary white spaces.

Example:  
Elvis Presley /Brel, Jacques/ Gabriele Susanne Kerner [Nena]  
will  
Presley, Elvis/Brel, Jacques/Kerner, Gabriele Susanne [Nena]

Action group

1. action: regular expression (trim white spaces)  
Field: `ARTIST`  
Regular expression: `^\s+|\s+$`  
Replace with: (nothing)

2. action: regular expression (multiple white spaces replace to 1)  
Field: `ARTIST`  
Regular expression: `\s{2,}`  
Replace with: `" "` (whitout quotation marks)

3. action: replace (delete white space after opening bracket)  
Field: `ARTIST`  
Original: `"[ "` (whitout quotation marks)  
Replace with: `[`

4. action: replace (delete white space before closing bracket)  
Field: `ARTIST`  
Original: `" ]"` (whitout quotation marks)  
Replace with: `]`

5. action: split fields by separator (for the next actions)  
Field: `ARTIST`  
Separator: `/`

6. action: regular expression (switches names without nickname)  
Field: `ARTIST`  
Regular expression: `^([^,[]+)\s([^,[]+)$`  
Replace with: `$2, $1`

7. action: regular expression (switches names with nickname)  
Field: `ARTIST`  
Regular expression: `^([^,[]+)\s([^,[]+)\s(\[.+\])$`  
Replace with: `$2, $1 $3`

8. action: merge duplicate fields (...back)  
Field: `ARTIST`  
Separator: `/`

---

<div class="post-metadata">

### Author: ![Zoofield](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zoofield/32/136_2.png) [@Zoofield](https://community.mp3tag.de/u/Zoofield)
#### Post date: [June 27, 2010, 4:34pm UTC](https://community.mp3tag.de/t/regular-expressions/521/28 "2010-06-27T16:34:58Z")

</div>

These are my Reg-Expressions there may be duplicates to what have previously been posted, or there are small changes to fix the many errors that the posted Reg-Expressions create. I have done a lot of testing to make sure these do what they say they do and nothing else. I hope this also allows me a place to create a back up.  
Thank-you! Updated: (June/10/2011) Mp3tag 2.49

**Action Group:Aa**

```
RE: Remove track number from title, ex."1 - Title" < "Title".
Field:TITLE
re:^\s*\d+\s*-\s*
Nothing:

RE: Remove "The" from artist, ex."The Artist" < "Artist".
Field:ARTIST
re:^The\s+
Nothing:

Case conversion:
Field:_TAG
Case conversion:Mixed Case
/[({"-_

RE:Capitalize Roman Numerals up to 399. (trimmed down from 3999
RE:to reduce false positives) - <a href="http://bit.ly/lZdZsj" target="_blank">http://bit.ly/lZdZsj</a>
Field:_Tag
re:(?<!')\b(?=[CLXVI])((C{0,3})?((X[LC])|(L?X{0,3})|L)?((I[VX])|(V?(I{0,3}))|V)?)\b
$upper($0)

RE: Capitalize Zero stop Acronyms and Initialisms. - <a href="http://bit.ly/jADbI6" target="_blank">http://bit.ly/jADbI6</a>
Field:_Tag
re:(?:frowning:?<=[^\w\']|\_)|(?<=^))(ac|ad|afi|aol|asap|atm|bbc|bc|bce|blt|btw|cc|cia|crc|cst|csv|dc|dfa|dj|d
mv|doa|dst|eod|ep|est|et|faq|fbi|fm|gi|glc|gmo|imo|imho|iq|ira|jc|irs|krs|la|lp|
m
c|mst|mtd|nasa|oj|pc|pi|pj|pm|ps|qed|rv|sos|ssr|usa|ussr|tba|tbd|teotwawki|tlc|t
v
|ufo)(?=[^\w\']|\_|$)(\.*)
$upper($1)

RE: Capitalize the Letter Infront of a period. A.B.C.
Field:_Tag
re:(?<=\.)([^\W\d\_])
$upper($1)

RE: Capitalize the Letter Infront of a Space and Apostrophe.
Field:_Tag
re:(?<=\s')([^\W\d\_])
$upper($1)

RE: Lower Case Prepositions, Articles and, Coordinating Conjunctions.
Field:_Tag
re:(?<=\w\s)(a|as|at|an|about|above|across|after|against|along|alongside|although|amo
ng|and|around|as|at|because|before|behind|below|beneath|beside|between|beyond|bu
t
|by|de|despite|down|during|even|except|excepting|for|from|if|in|inside|into|like
|
near|next|nor|of|off|on|onto|or|out|outside|over|past|regarding|round|since|so|t
h
an|the|through|throughout|till|to|toward|under|underneath|unlike|until|up|upon|v
o
n|when|while|with|within|without|yet)(?=\s\w)
$lower($0)

RE: Lower Case Abbreviations, Add Stop.
Field:_Tag
re:(?<=[^\w\']|\_)(alt|ave|capt|cent|corp|div|ed|eg|etc|fag|feat|gen|hr|ie|inc|inst|lb|ltd|
min|mt|op|pl|pop|pseud|pt|pub|rev|sec|ser|sgt|st|univ|vs|vol)(?=[^\w\']|\_)(\.*)
$lower($1).

RE: Add Space Before, & ( { [ + =
Field:_Tag
re:([^\W\_])([&\(\{\[\+\=])
$1 $2

RE:Add Space After, & ) } ] ; : , ! + =
Field:_Tag
re:([&\)\}\]\;\:\,\!\+\=])([^\W\_])
$1 $2

RE: Add Space After, . <a href="http://bit.ly/jADbI6" target="_blank">http://bit.ly/jADbI6</a>
Field:_Tag
re:(?<!^)(?<!\d|\s|\.)(\.)([^\W\d\_])(?!\.|\s|$)
$1 $upper($2)

RE: Add Space After, " "
Field:_Tag
re:(".*?")([^\W\_])(?!$)
$1 $2

RE: Add Space Before, " "
Field:_Tag
re:([^\W\_])(".*?")
$1 $2

RE: Remove Spaces After, ( [{ Before,] } ) ? : ; , ! .
Field:_Tag
re:([\(\[\{])\s+|\s+([\]\}\)\?\:\;\,\!\.])
$1$2

RE: Remove Spaces Before / After.
Field:_Tag
re:\s+(\/)\s+
$1

RE: Remove Spaces inside, " "
Field:_Tag
re:"\s*(.*?)\s*"
"$1"

RE: Remove Spaces Before and After String.
Field:_Tag
re:^\s+|\s+$
Nothing:

RE: Remove all Double+ Spacing.
Field:_Tag
re:\s{2,}
One Space:

RE: Add Apostrophe to Are Contractions.
Field:_Tag
re:\b(how|they|what|when|where|why|you)re(?=[^\w\']|\_|\$)
$1're

RE: Add Apostrophe to Had/Would Contractions.
Field:_Tag
re:\b(he|how|i|it|she|they|we|what|where|who|why|you)d(?=[^\w\']|\_|\$)
$1'd

RE: Add Apostrophe to Have Contractions.
Field:_Tag
re:\b(could|how|i|might|must|should|we|what|when|where|would|you)ve(?=[^\w\']|\_|\$)
$1've

RE: Add Apostrophe to Is Contractions.
Field:_Tag
re:\b(he|here|how|it|let|she|that|there|two|what|when|where|who|why)s(?=[^\w\']|\_|\$)
$1's

RE: Add Apostrophe to Not Contractions.
Field:_Tag
re:\b(ain|aren|can|couldn|didn|doesn|don|hadn|hasn|haven|isn|mightn|mustn|shoul
dn|wasn|weren|won|wouldn)t(?=[^\w\']|\_|\$)
$1't

RE: Add Apostrophe to Will Contractions.
Field:_Tag
re:\b(how|i|it|she|that|there|they|what|when|where|who|why|you)ll(?=[^\w\']|\_|\$)
$1'll

RE: Add Apostrophe to Am Contractions.
Field:_Tag
re:\b(i)m(?=[^\w\']|\_|\$)
$1'm

RE: Add Apostrophe to Do Ya Contraction.
Field:_Tag
re:\b(D)ya(?=[^\w\']|\_|\$)
$1'ya

RE: Add Apostrophe to Do You Contraction.
Field:_Tag
re:\b(D)you(?=[^\w\']|\_|\$)
$1'you

RE: CamelCase Mc Words.
Field:_Tag
re:\bMc(?=.)
Mc$upper($1)

RE:CamelCase O' Words.
Field:_Tag
re:\bO'([^\W\d\_e])
O'$upper($1)

```

[mp3tagRegExpressions.txt](https://community.mp3tag.de/uploads/default/original/2X/2/2914bfebe01be8e2579a495185014b2bdf6236b4.txt) (6.23 KB)

---

<div class="post-metadata">

### Author: ![d003232](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/fbc32d/32.png) [@d003232](https://community.mp3tag.de/u/d003232)
#### Post date: [August 16, 2010, 8:38am UTC](https://community.mp3tag.de/t/regular-expressions/521/29 "2010-08-16T08:38:38Z")

</div>

My title and/or filename looks like:

**Gospel&spiritual 1 - Track 03.[128kb 44khz 2'34]**

I want to delete the suffix: '.[128kb 44khz 2'34]'.

I do it the way:

**Field:** `TITLE`  
**RegExp:** `(.*)\.\[[0-9]+kb\s[0-9]+khz.*\]`  
**Replace with:** `$1`

Just change that to the field \_FILENAME if you want to do it for the filename.

If you want to take a more easy solution (for example delete everything after the first dot, ...) see the next posts from DetlevD or RevRagnarok.

Update: Added a `'\'` befor the dot, to make sure, only a real dot before the `'['` will be replaced, thx to RevRagnarok for the hint.

---

<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: [August 16, 2010, 2:22pm UTC](https://community.mp3tag.de/t/regular-expressions/521/30 "2010-08-16T14:22:25Z")

</div>

> [@d003232](#):
>
> ...**Gospel&spiritual 1 - Track 03.[128kb 44khz 2'34]**... I want to delete the suffix: '.[128kb 44khz 2'34]' ...

This is a good example for the situation, where someone does not really need to learn the regular expression language, but instead use a simple action.

_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%TITLE%**  
_Guessing pattern:_ **%TITLE%.%DUMMY%**  
From:  
Gospel&spiritual 1 - Track 03.[128kb 44khz 2'34]  
To:  
Gospel&spiritual 1 - Track 03

DD.20100816.1822.CEST

---

<div class="post-metadata">

### Author: ![RevRagnarok](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@RevRagnarok](https://community.mp3tag.de/u/RevRagnarok)
#### Post date: [August 17, 2010, 10:57am UTC](https://community.mp3tag.de/t/regular-expressions/521/31 "2010-08-17T10:57:14Z")

</div>

> [@d003232](#):
>
> I do it the way:
> 
> **Field:** TITLE  
> **RegExp:** `(.*).\[[0-9]+kb\s[0-9]+khz.*\]`  
> **Replace with:** `$1`

FYI, that is slightly incorrect. It will actually remove 1 character from before the '[' which in your example is '.' - you need to escape the '.' to ensure it is a '.':  
**Field:** `TITLE`  
**RegExp:** `(.*)<b>\</b>.\[[0-9]+kb\s[0-9]+khz.*\]`  
**Replace with:** `$1`

Another simpler option would be to just grab everything before the first dot:  
**Field:** `TITLE`  
**RegExp:** `([^\.]*)`  
**Replace with:** `$1`

Or if you want everything up to the first '[' but no period, why bother matching what is in the brackets unless you planned on parsing it for something else?

**Field:** `TITLE`  
**RegExp:** `(.*)\.\[`  
**Replace with:** `$1`

_I am at work, so this is all untested RE code._

---

<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: [August 31, 2010, 7:33am UTC](https://community.mp3tag.de/t/regular-expressions/521/32 "2010-08-31T07:33:02Z")

</div>

**Roman numerals in uppercase**

This "Regular Expression" changes Roman numerals in uppercase.  
Valid range of numbers: "I" to "MMMCMXCIX" (decimal: 1-3999).

Dieser "Reguläre Ausdruck" ändert römische Ziffern in Großbuchstaben.  
Gültiger Zahlenbereich: "I" bis "MMMCMXCIX" (dezimal: 1-3999).

Example  
From:  
"ab **i** ab **ii** ab **iii**  **iv**  **v** vv **vi**  **vii**  **viii**  **ix** abc **x**  **mcmliv**  **ll** cmm **mmix-ix-xi**"  
To:  
"ab **I** ab **II** ab **III**  **IV**  **V** vv **VI**  **VII**  **VIII**  **IX** abc **X**  **MCMLIV**  **ll** cmm **MMIX-IX-XI**"

```
$regexp(%TITLE%,'\b(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?X{0,3})|L)?((I[VX])|(V?(I{0,3}))|V)?))\b','\U$0')

```

Alternative:  
(using the 'ignore case' parameter of the Mp3tag $regexp function instead of regex modifier)

```
$regexp(%TITLE%,'\b(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?X{0,3})|L)?((I[VX])|(V?(I{0,3}))|V)?)\b','\U$0',1)

```

Attached is a Mp3tag mte export script, which visualizes the results of three attempts using regular epressions, which are able to upcase Roman Numerals in different quality.  
[Test.RomanNum.Upcase.zip](https://community.mp3tag.de/uploads/default/original/2X/6/6fde8ef02bcc14e22faf26f9799a112853e27f3c.zip) (1.95 KB)

DD.20100831.1133.CEST  
Edit. Spelling error in RegEx corrected and zip file attached.  
DD.20110320.1518.CET

[Test.RomanNum.Upcase.zip](https://community.mp3tag.de/uploads/default/original/2X/6/6fde8ef02bcc14e22faf26f9799a112853e27f3c.zip) (1.95 KB)

---

<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: [September 17, 2010, 3:02pm UTC](https://community.mp3tag.de/t/regular-expressions/521/33 "2010-09-17T15:02:33Z")

</div>

**Splitting an "Upper Camel Case" string**

The following "Regular Expression" splits an "Upper Camel Case" string into components by inserting a space character before any Word which starts with a capital letter or digit.

Der folgende "Reguläre Ausdruck" teilt eine Zeichenkette mit Binnenmajuskeln in Komponenten auf durch Einfügen eines Leerzeichens vor jedem Wort, das mit einem Großbuchstaben oder einer Ziffer beginnt.

Example  
From:  
"ThisIsThe2ndSongFromD.D.'sFirstAlbum30YearsAgo."  
To:  
"This Is The 2nd Song From D.D.'s First Album 30 Years Ago."

```
$regexp(%_FILENAME%,'(?<!^)(\u\l|(?<=\l)[\u\d])',' $1')

```

DD.20100917.1902.CEST

![](https://community.mp3tag.de/uploads/default/original/2X/2/2d925e7cc0a836863b86021fbe60bca664165c84.png)

Edit.DD.20110816.1848.CEST

![](https://community.mp3tag.de/uploads/default/original/2X/2/2d925e7cc0a836863b86021fbe60bca664165c84.png)

---

<div class="post-metadata">

### Author: ![InspectorMustache](https://community.mp3tag.de/user_avatar/community.mp3tag.de/inspectormustache/32/314_2.png) [@InspectorMustache](https://community.mp3tag.de/u/InspectorMustache)
#### Post date: [December 5, 2010, 11:09pm UTC](https://community.mp3tag.de/t/regular-expressions/521/34 "2010-12-05T23:09:10Z")

</div>

> [@nickless](#):
>
> This RegEx will convert abbreviations composed of single chars and points between (and/or behind it) to uppercase.  
> Single chars without points around remains lowercase, except if a "-"char and a space is before it. (Example: "Songname - A text")

This didn't work for me. I tried to make my own and came up with this simple RegEx to get the cases right in my tags:

**REGULAR EXPRESSION** :  
\b(?\<!')(\w)  
**REPLACE WITH** :  
\u\1

This works for me. You can apply this to the \_ALL field but be aware that this capitalizes your extensions too. If this looks somehow annoying to you (as it does to me), simply apply this to the \_FILENAME field afterwards:

**REGULAR EXPRESSION** :  
.([^.]+)$  
**REPLACE WITH** :  
.\L\1\E

These are both pretty simple but I spent quite a time figuring out how to make these apply for Unicode. I finally found out that Mp3tag has Unicode functionality standardly implemented into its RegEx engine. Heh. 😃

Edit: Here's some improvement. The last one only replaced the first letter of the word and put it into upper case disregarding the rest of the word. This one also puts those that follow the first letter into lower case ("DAItro" becomes "Daitro"):

**REGULAR EXPRESSION** :  
\b(?\<')([a-zA-Z])([^']\*?)\b  
**REPLACE WITH** :  
\u\1\L\2\E

This next one is basically the same but takes note of the French article L' and puts the letter following the article into upper case. So, for example, "L'eau" becomes "L'Eau".

**REGULAR EXPRESSION** :  
\b(?\<!(?\<!\s[Ll])')([a-zA-Z])([^']\*?)\b  
**REPLACE WITH** :  
\u\1\L\2\E

---

<div class="post-metadata">

### Author: ![vinillum](https://community.mp3tag.de/user_avatar/community.mp3tag.de/vinillum/32/340_2.png) [@vinillum](https://community.mp3tag.de/u/vinillum)
#### Post date: [December 15, 2010, 12:39am UTC](https://community.mp3tag.de/t/regular-expressions/521/35 "2010-12-15T00:39:01Z")

</div>

Script to fix capitalization according to English rules only in tags. This is my n-th attempt to do this, but I think it works quite nice... Of course some human work is needed because it doesn't contain corpus to check it according to its POS.

```
[#0]
T=1
F=_TAG
1=1
2=

[#1]
T=4
F=_TAG
1=\\\\b(A|An|The|And|But|Or|So|After|Before|Out|When|While|Since|Until|Although|Even If|Because|About|Above|Across|Against|Along|Alongside|As|At|Below|By|During|For|
From|In|Into|Of|Off|On|Onto|Over|Than|Through|Till|To|Under|Up|With|Within|Witho
u
t)\\\\b
2=$lower($1)
3=0

[#2]
T=4
F=_TAG
1=^\\\\s*(\\\\w+)
2=$caps($1)
3=0

[#3]
T=4
F=_TAG
1=(\\\\w+)\\\\s*$
2=$caps($1)
3=0

```

Or directly in mp3tag:  
**Case conversion**  
_Field_ \_TAG  
_Case conversion_ Mixed Case  
_Words begin..._

**Replace with regular expression**  
_Field_ \_TAG  
_Regular expression_ \b(A|An|The|And|But|Or|So|After|Before|Out|When|While|Since|Until|Although|E  
ven If|Because|About|Above|Across|Against|Along|Alongside|As|At|Below|By|During|For|  
From|In|Into|Of|Off|On|Onto|Over|Than|Through|Till|To|Under|Up|With|Within|Witho  
u  
t)\b  
_Replace matches with_ $lower($1)

**Replace with regular expression**  
_Field_ \_TAG  
_Regular expression_ ^\s\*(\w+)  
_Replace matches with_ $caps($1)

**Replace with regular expression**  
_Field_ \_TAG  
_Regular expression_ (\w+)\s\*$  
_Replace matches with_ $caps($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: [January 10, 2011, 5:09pm UTC](https://community.mp3tag.de/t/regular-expressions/521/36 "2011-01-10T17:09:55Z")

</div>

**Regular Expression Tutorial**

Beginner or Professional!  
Please take a few minutes and look this presentation (slideshow or PDF):

**Andrei’s Regex Clinic**

This is an outstanding work, which visualises the world of Regular Expressions in a wide manner.  
The tutorial can help to open your mind.

[http://zmievski.org/c/dl.php?file=talks/co...egex-clinic.pdf](http://zmievski.org/c/dl.php?file=talks/confoo-2010/regex-clinic.pdf)  
[http://www.slideshare.net/andreizm/andreis-regex-clinic](http://www.slideshare.net/andreizm/andreis-regex-clinic)  
[http://zmievski.org/2010/05/regex-clinic-on-slideshare](http://zmievski.org/2010/05/regex-clinic-on-slideshare)

DD.20110110.1912.CET

---

<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: [January 10, 2011, 7:02pm UTC](https://community.mp3tag.de/t/regular-expressions/521/37 "2011-01-10T19:02:07Z")

</div>

> [@DetlevD](#):
>
> **Regular Expression Tutorial**
> 
> Beginner or Professional!  
> Please take a few minutes and look this presentation (slideshow or PDF):
> 
> **Andrei’s Regex Clinic**

Are all the things described there useable for mp3tag?

---

<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: [January 10, 2011, 7:09pm UTC](https://community.mp3tag.de/t/regular-expressions/521/38 "2011-01-10T19:09:01Z")

</div>

> [@pone](#):
>
> Are all the things described there useable for mp3tag?

Probably not, one must abstract.

DD.20110110.2111.CET

---

<div class="post-metadata">

### Author: ![Doug\_Mackie](https://community.mp3tag.de/user_avatar/community.mp3tag.de/doug_mackie/32/279_2.png) [@Doug\_Mackie](https://community.mp3tag.de/u/Doug_Mackie)
#### Post date: [January 13, 2011, 5:55pm UTC](https://community.mp3tag.de/t/regular-expressions/521/39 "2011-01-13T17:55:35Z")

</div>

**To Juozas V:**  
Thank you very much for this. It does the best English title case conversion that I have seen here.

However, I have one minor quibble. Your word list includes some words and phrases that I see more often used in song titles as subordinate conjunctions than as prepositions. For example "after", "because", and "although". From my reading on capitalization in titles, subordinate conjunctions should always be capitalized. Since it's not practical to use script to detect how a word is used, I chose to remove those words from your Reg Ex on the basis that there should be fewer errors without them than with them. The words that I removed are:

After, As, Although, Because, Even If, Since, Till, Until, When, and While.

Here is my revised word list (resorted alphabetically):

**A|About|Above|Across|Against|Along|Alongside|An|And|As|At|Before|Below|But|By|Du  
ring|For|From|In|Into|Nor|Of|Off|On|Onto|Or|Out|Over|So|Than|The|Through|To|Unde  
r  
|Up|With|Within|Without**

Note that I also added the coordinating conjunction "Nor" to your list.

Best regards,  
Doug M. in NJ

---

<div class="post-metadata">

### Author: ![LosMintos](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/54ee81/32.png) [@LosMintos](https://community.mp3tag.de/u/LosMintos)
#### Post date: [April 18, 2011, 5:55pm UTC](https://community.mp3tag.de/t/regular-expressions/521/40 "2011-04-18T17:55:25Z")

</div>

Convert MP3tag's date to ISO date

Converts (example) 18.04.2011 to 2011-04-18.

_format tag field_  
Field: date added  
Format string: %\_date%

_replace with regular expression_  
Field: date added  
RegExp: ^(\d+).(\d+).(\d+)$  
Replace with: $3-$2-$1

[Previous page](https://community.mp3tag.de/t/regular-expressions/521.md?page=1)

[Next page](https://community.mp3tag.de/t/regular-expressions/521.md?page=3)
