'Capitalize First Letter of Every Word inside Bracket

I'm trying to write some useful Regex for Tagscanner (a music tagger on Windows) and spent a bunch of time on regex101.com to fulfill my idea.

In some language like French, it's a huge pain to make the title look good if you capitalize every word. I just want to capitalize the first letter of every word in round bracket. I will receive the string like this :

Edith Piaf - La vie en rose (louis armstrong 2015 version)

I started with this base :

/([a-z])([\w-']*)([\s\)\]\,;\d]*|$)/gi
that I replace by \U\1\E\2\3

([a-z]) I try to capture the letter I want in uppercase
([\w-']*) What I expect to be the rest of the word
([\s\)\]\,;\d]|$) Delimiters

This will actually Capitalize everywhere correctly in the title, then the problems come...

I tried to ignore everything until I encounter '('

\(\K or \({1} or with \(\A or \((*SKIP) etc...

Positive lookbehind (?<=() doesn't work either because after my first match it will look if I have '(' again.

Also tried to capture the whole thing and put * after doesn't work either.

I just don't know how to do it. Thank you very much for helping!



Solution 1:[1]

With Perl's rename from @Wiktor Stribi?ew's regex:

rename -n 's/(?:\G(?!^)|\()[^()]*?\K\b(\p{Ll})(\w*)/\U$1\E$2/gmu'  Edith*

Remove -n switch when the output looks good.

warning There are other tools with the same name which may or may not be able to do this, so be careful.

cpan standalone script

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glorfindel