Capitalize first letter of each word


I’ve been banging my head against the wall on trying to handle disambiguation in a more standard way. But my current issue is that $rreplace does not seem to handle using a function such as $upper. Here is a stripped down version of what I’m trying to do:

$set(album,%album% \($rreplace(%_releasecomment%,%_firstLetter%,%_upperLetter%)\))

No matter how many times I’ve tried to tweak this, it never returns the uppercase value of the first letter. If I replace %_upperLetter% with something like TEST, it will return TESTeluxe TESTdition. So my regex is at least capturing the right stuff.


Double-checking the Picard scripting functions list, $rreplace() is of course “replace by searching for a regular expression”. I looked for a $sentencecase() or $caps2() function, but I don’t see them.

I see two things that puzzle me in your second statement, $set(_upperLetter,$upper(\\1)).

First, when is the $upper() call executed? Just looking at it, it seems it should be executed when the second statement runs. This means that %_upperLetter% will always have the value \1, not $upper(\1).

Second, I assume that you want the \1 value passed to $rreplace() to be replaced by whatever matches the regular expression \w. Does $rreplace() promise to perform that kind of match group replacement? The documentation is very skimpy, but it doesn’t promise this that I can see.

So, if my observations are valid, maybe the conclusion is: this is the sort of text manipulation which is too hard for Picard’s scripting language. You might have to write a Picard plugin instead. That gives you access to the full power of the Python scripting language.

I hope this is helpful. Good luck!
—Jim DeLaHunt


Interesting point. I think I tried it in the $set album statement directly, too. I’ll try that again, but had a funny feeling it might lead to me writing a plugin…

Thanks for the pointers.