# Weird behavior after applying regex

**URL:** <https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176>\
**Category:** Support\
**Created:** [May 11, 2021, 4:43am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176 "2021-05-11T04:43:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![1024mb](https://community.mp3tag.de/user_avatar/community.mp3tag.de/1024mb/32/5653_2.png) [@1024mb](https://community.mp3tag.de/u/1024mb)\
**Post date:** [May 11, 2021, 4:43am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/1 "2021-05-11T04:43:26Z")

</div>

So I'm using this as an action "Replace with regular expression" to make all the text inside the brackets change to title case:

Field: `TITLE`  
Regular expression: `(.*)(\()(.*)(\))(.*)`  
Replace matches with: `$1$2$caps2($3)$4$5`

But if the text inside the brackets has any comma it gets all messed up.  
For example MP3Tag turned this:

`Papercut (live at Docklands Arena, London)`

Into this:

`Papercut (lIve At DoCklAndS ArenA)`

And I don't understand what I'm doing wrong, all of that regex looks OK. Can someone help? All I can think of is that this is a bug.

---

<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 11, 2021, 5:45am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/2 "2021-05-11T05:45:22Z")

</div>

Irrespective of your finding ...  
(where I tried to find out what was going on with Converter\>Tag-Tag and $regexp()- but that function produces a different result from the action)  
I think it has to do with the greadiness of the function. Except for the brackets you do not supply any separator so that the expression can find out where one `(.*)` ends and the next one starts. Also, the supplied string is empty for `$5` as nothing follows the closing bracket. This may be tolerable, I still see it as somewhat untidy.

In respect to the problem:  
If you want to use the brackets as word boundary indicator why don't you use the case conversion action and add the opening bracket to the list of characters after which a letter gets capitalized. Here you can add further characters like punctuation, other brackets, hyphens etc.

---

<div class="post-metadata">

**Author:** ![1024mb](https://community.mp3tag.de/user_avatar/community.mp3tag.de/1024mb/32/5653_2.png) [@1024mb](https://community.mp3tag.de/u/1024mb)\
**Post date:** [May 11, 2021, 6:12am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/3 "2021-05-11T06:12:56Z")

</div>

I thought about that but I didn't know how to tell the engine that there is no separator, or how to escape the backreference, obviously enclosing it with quotes doesn't work. `$5` is there because sometimes there is something like `Title One (Live at XXXXXXX) [PepeLePew Remix]` and I don't want to loose that last part of the `title`.

> [@ohrenkino](#):
>
> why don't you use the case conversion action and add the opening bracket to the list of characters after which a letter gets capitalized

I tried that but as I said, sometimes there is still text after the last bracket and that action changes the case of everything after the selected character (first -opening- bracket). For most cases it works but I can't use that as an automated action.

---

<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:** [May 11, 2021, 6:16am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/4 "2021-05-11T06:16:08Z")

</div>

If you expand the string, you can see that it's the result of applying `$caps2(live at Docklands Arena, London)`, where the "second parameter" `London` is specifies the characters that trigger upper case.

You'd need to take care of those commas in your regular expression if you want to use $caps2() on the result.

---

<div class="post-metadata">

**Author:** ![1024mb](https://community.mp3tag.de/user_avatar/community.mp3tag.de/1024mb/32/5653_2.png) [@1024mb](https://community.mp3tag.de/u/1024mb)\
**Post date:** [May 14, 2021, 9:14am UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/5 "2021-05-14T09:14:51Z")

</div>

Thanks for the info. Do you have any idea as to how can I achieve that?

---

<div class="post-metadata">

**Author:** ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)\
**Post date:** [May 14, 2021, 2:49pm UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/6 "2021-05-14T14:49:30Z")

</div>

Here's one idea:  
Replace commas with something unique, apply the regex, then reverse the original replacement.

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [May 14, 2021, 8:32pm UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/7 "2021-05-14T20:32:03Z")

</div>

I have been using the unicode character U+201A "Single Low-9 Quotation Mark" as it looks virtually identical on-screen and does NOT interfere with any scripting or regex. I didn't even change it back. It is applied to all Title, Album, Artist, AlbumArtist, and Composer tags in my library. The hardest part is remembering this when adding new tags. In Windows you can use Alt+0130 as well.  
Standard Comma ,  
Single Low Quote ‚

---

<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:29pm UTC](https://community.mp3tag.de/t/weird-behavior-after-applying-regex/53176/8 "2026-02-09T12:29:13Z")

</div>


