# Replace with regular expression ... weirdness

**URL:** <https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911>\
**Category:** Support\
**Created:** [May 20, 2015, 8:40am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911 "2015-05-20T08:40:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Audio\_ELF](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Audio\_ELF](https://community.mp3tag.de/u/Audio_ELF)\
**Post date:** [May 20, 2015, 8:40am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/1 "2015-05-20T08:40:15Z")

</div>

Okay ... can anyone give me an explanation why the following "Replace with regular expression" gives me the weirdness it does...

```
Field: Comment
Regular expression: (".*")
Replace matches with: $caps($1)

```

so with most things it works as expected so...  
**from "a new flame"**  
becomes  
**from "A New Flame"**

but...  
**from "wednesday morning, 3 a.m."**  
becomes  
**from "WednesdaY mOrning**

Just to clarify; I'm wanting to capitalise everything within the " marks. I'm sure theres something simple I've missed and it's the , thats causing the trouble. Just don't know why and the (seemingly) random capitals are really weird!

Eloise

---

<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:** [May 20, 2015, 8:47am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/2 "2015-05-20T08:47:00Z")

</div>

If you want to modify the format of a complete field, I would use an action of the type "Format tag-field", in this case for COMMENT.  
Format string: $caps(%comment%)

---

<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:** [May 20, 2015, 9:20am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/3 "2015-05-20T09:20:29Z")

</div>

There seems to be a misunderstanding of how to use the Action "Replace using Regular Expression".

> [@Eloise](#):
>
> ... Just to clarify; I'm wanting to **capitalise everything** within the " marks. ...

**Action: Format value Field : COMMENT Formatstring: $upper(%COMMENT%) From: "wednesday morning, 3 a.m." To : "WEDNESDAY MORNING, 3 A.M."**

... or ... maybe you want to do ...

**Action: Format value Field : COMMENT Formatstring: $caps(%COMMENT%,'" .') From: "wednesday morning, 3 a.m." To : "Wednesday Morning, 3 A.M."**

... and you should consider, whether it is allowed to apply a Mp3tag scripting function like $caps() within the replacement part of the Action "Replace using Regular Expression".

Your example let assume that the embedded function $caps uses the part of the $1 parameter, following the comma, as the second parameter for its own parameter list.  
Therefore the characters 'a' and 'm' and the other ones trigger the upcasing of the following letter, ...  
e. g. from 'mo' to 'mO'.

The expression **$caps($1)** will be resolved to ... **$caps(from "wednesday morning, 3 a.m.")**.  
Therefore the function $caps works as designed: ...  
change each letter to upcase character when following one character, ...  
which is defined in the character set ' ."3am' (space,dot,double-apostrophe,3,a,m).  
Therefore the output is ...  
_from **"** Wednesd **a** Y **m** Orning"_  
This looks correct.

Upcase all characters, which are enclosed in double apostrophes at end of the given string ...

**Action: Format value Field : COMMENT Formatstring: $regexp(%COMMENT%,'^(.+?)(".+?")$','$1\U$2') From: from "wednesday morning, 3 a.m." To : from "WEDNESDAY MORNING, 3 A.M."**

Upcase each character, when it has a leading space, double-apostrophe, point character ...

**Action: Format value Field : COMMENT Formatstring: $regexp(%COMMENT%,'(?\<=[".])(.)','\u$1$2') From: from "wednesday morning, 3 a.m." To : from "Wednesday Morning, 3 A.M."**

DD.20150520.1354.CEST, DD.20150520.1618.CEST

---

<div class="post-metadata">

**Author:** ![Audio\_ELF](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Audio\_ELF](https://community.mp3tag.de/u/Audio_ELF)\
**Post date:** [May 20, 2015, 10:47am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/4 "2015-05-20T10:47:07Z")

</div>

> [@ohrenkino](#):
>
> If you want to modify the format of a complete field, I would use an action of the type "Format tag-field", in this case for COMMENT.  
> Format string: $caps(%comment%)

That wouldn't work (as I want it to)...

I think you slightly (as did the other reply below yours) misread my post (or I wasn't clear).

The complete tag for comment is: **from "wednesday morning, 3 a.m."** - so everything in bold including the word **from**.

I only want to capitalist the part within "quotes".

If I can't do this then fine, but just curious why it works in some cases, but not in others. I do now have an explanation, just not sure if (a) I'm doing something Florian never intended to work or (🕶 there is a bug which I've discovered.

---

<div class="post-metadata">

**Author:** ![Audio\_ELF](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Audio\_ELF](https://community.mp3tag.de/u/Audio_ELF)\
**Post date:** [May 20, 2015, 11:11am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/5 "2015-05-20T11:11:07Z")

</div>

> [@DetlevD](#):
>
> Your example let assume that the embedded function $caps uses the part of the $1 parameter, following the comma, as the second parameter for its own parameter list.  
> Therefore the letters 'a' and 'm' trigger the upcasing of the following letter, to change to 'Y' and 'O'.
> 
> DD.20150520.1354.CEST

Ahh I think I understand what you are saying ...

The command is being interpreted as **$caps(wednesday morning, 8 A.M.)**  
so its looking for a new word after every A and every M as well as after a . and a [space].

I have seen similar functions mentioned (such as uppercase letter in names after a Mc or Mac ... but perhaps not quite as complicated ...

---

<div class="post-metadata">

**Author:** ![Audio\_ELF](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@Audio\_ELF](https://community.mp3tag.de/u/Audio_ELF)\
**Post date:** [May 27, 2015, 11:21am UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/6 "2015-05-27T11:21:35Z")

</div>

Just as a follow up...

I ended up adding a replace , with § before the replace with regular expression command, then afterwards replace § with , and it all works fine. Just need to remember can't use such commands where , are in the string.

---

<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:25pm UTC](https://community.mp3tag.de/t/replace-with-regular-expression-weirdness/16911/7 "2026-02-09T12:25:40Z")

</div>

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


