# Capitalizing sentence with commas inside parentheses

**URL:** https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985
**Category:** Support
**Created:** [May 17, 2020, 5:41pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985 "2020-05-17T17:41:30Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 5:41pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/1 "2020-05-17T17:41:30Z")

</div>

Hello fellow members. Long time no see!

I'm trying to capitalize only the first letter of the following strings inside parentheses:

4:47AM (The Remains of Our Love)

5:01AM (The Pros and Cons of Hitch Hiking, Pt. 10)

The regex i have been trying to figure out:

(.+)(?=\s()\s?((([a-zA-Z0-9 .,]+?)))

The first title is parsed correctly but the second is parsed in mixed case supressing all the characters that follow the comma:

The pRos And Cons Of HitCh Hiking

Could you help me figure out where i did go wrong with my regex?

Thank you.

---

<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 17, 2020, 5:56pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/2 "2020-05-17T17:56:53Z")

</div>

> [@malganis](#):
>
> (.+)(?=\s()\s?((([a-zA-Z0-9 .,]+?)))

Somehow I am missing how you treat the result.  
Or: I can see the source string - but what should the target string look like?  
Also, I am used to regular expressions that use a $1 etc. as result output unless you want to delete something.  
When I test  
`$regexp('5:01AM (The Pros and Cons of Hitch Hiking, Pt. 10)',(.+)(?=\s()\s?((([a-zA-Z0-9 .,]+?))),$1)`  
I get a syntax error.  
So: does the forum formatter show everything correctly? It may be advisable to enclose the expression in accent grave.

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 6:31pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/3 "2020-05-17T18:31:37Z")

</div>

Hi ohrenkino!

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

![image](https://community.mp3tag.de/uploads/default/original/2X/3/34d656417748a2f753b891f4606a91b355904a4e.png)

Outputs:

The pRos And Cons Of HitCh Hiking

The expected result should be:

5:01AM (The pros and cons of hitch hiking, pt. 10)

---

<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 17, 2020, 6:57pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/4 "2020-05-17T18:57:21Z")

</div>

Doesn't this problem resemble a little this one:

> [@Move "Featuring" from Artist to Title](https://community.mp3tag.de/t/move-featuring-from-artist-to-title/11096/56):
>
> You have mixed something into the $regexp() function, which might be not allowed ... or does not work per se, ... which is here ... the function $caps2(). You may do what you want in a following second step ... Action "Format value" Tag-Field : ARTIST Formatstring: $regexp(%ARTIST%,'^(.+\sfeat.\s)(.\*)$','$1')$regexp($regexp(%ARTIST%,'^(.+\sfeat.\s)(.\*)$','$2'),'\b\w\*\b','\u$0') ... or ... Formatstring: $regexp(%ARTIST%,'^(.+\sfeat.\s)(.\*)$','$1')$caps2($regexp(%ARTIST%,'^(.+\sfeat.\s)(.…

You describe a pattern with 3 parts but only the third gets treated.  
I do not think that you can "replace" that but you have "Format value" the field again with a separate string function for each part that you then have to isolate with a regular expression each.  
If you use $caps() you may have to define the characters that determine the word separator.  
I tried the following:  
`$caps3($regexp('5:01AM (The Pros and Cons of Hitch Hiking, Pt. 10)','(.+) (\(.)(.*,.*\))',$1 $2$3),'(')`  
and got  
5:01am (The pros and cons of hitch hiking, pt. 10)

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 7:06pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/5 "2020-05-17T19:06:18Z")

</div>

In my example i isolated the third part for testing purposes only. Although your explanation makes sense i'm still trying to understand why this method is not suitable for achieving such result:

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

---

<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 17, 2020, 7:13pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/6 "2020-05-17T19:13:32Z")

</div>

I tried it in Convert\>Tag-Tag with $regexp()  
I am not quite sure if the preview works allright because that never shows any case conversion ...  
Please not that I appended function to  
`$caps3($3,'(')`  
to set the ( as word separator.

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 7:15pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/7 "2020-05-17T19:15:31Z")

</div>

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

![image](https://community.mp3tag.de/uploads/default/original/2X/0/08b4d80905cf9cbdb4f3e06e9aa5f2233095eaf6.png)

Results in:

5:01AM (THe pRos And Cons Of HitCh Hiking)

---

<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 17, 2020, 7:27pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/8 "2020-05-17T19:27:32Z")

</div>

It's the wrong part that gets the $caps-treatment. It should be $2

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 7:31pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/9 "2020-05-17T19:31:10Z")

</div>

My apologies for lack of attention though it will output a syntax error in format string.

---

<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 17, 2020, 7:34pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/10 "2020-05-17T19:34:16Z")

</div>

as I said: I do not think that you can use the $-functions in a "replace with" statement as this is not a format string.  
You would have to use a "Format value" action and 3 separate regular expressions to isolate the 3 parts so that you can treat the case of "Bracket plus character" individually.

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 7:43pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/11 "2020-05-17T19:43:22Z")

</div>

I use $-functions in a similarly fashion and they usually output the desired result. I'm quite aware that my regular expressions are sub-par but they work as intended. For instance:

![image](https://community.mp3tag.de/uploads/default/original/2X/4/485813f4a3023042dd2b9da3e4ef46f6f2d55911.png)

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

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 8:31pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/12 "2020-05-17T20:31:11Z")

</div>

Trying to a workaround that somehow proves that there must something related to mp3tag that's causing this bug to happen:

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

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

Outputs:

5:01AM (THE pros and cons of hitch hiking)

So i wonder why is mp3tag supressing all the characters followed by the comma including the comma itself?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [May 17, 2020, 9:37pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/13 "2020-05-17T21:37:10Z")

</div>

Having both regex syntax and the scripting functions (where the comma is a special character) here has limits.  
So if you have a comma in your tag field it breaks the function.

---

<div class="post-metadata">

### Author: ![malganis](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@malganis](https://community.mp3tag.de/u/malganis)
#### Post date: [May 17, 2020, 10:10pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/14 "2020-05-17T22:10:00Z")

</div>

I figured a workaround that satisfies both examples:

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

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

---

<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: [June 16, 2020, 10:10pm UTC](https://community.mp3tag.de/t/capitalizing-sentence-with-commas-inside-parentheses/48985/15 "2020-06-16T22:10:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
