Capitalize first letter of each word

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

1 Like