About using functions with regular expressions

When trying to use functions in the replace argument of the regexp function, the function is applied BEFORE the regular expression. It makes sense as it is the usual composition of functions.

For example, if I try to put minor keys in lower case in german notation, I'm tempted to do

$regexp(%title%,'(\w+)(?=-moll)',$lower('$1'))

Bu this of course transforms $1 to lowercase, that is, the same $1 string, before the regexp function evaluates it.
image

The question is then, how to apply functions to transform the captures of the regular expression in the replace format?

Thanks!

Jordi

I am not sure whether this is a valid example.
When the $1 returns the input string, then it means it has not found a hit.
If you want to replace one text constant with another then a simple $replace() would be sufficient - and that is also case sensitive.
The following expression would turn at least the first letter into a capital one:
$regexp(%title%,'(\w+)-(.*)(.*)',$1-\u$2$3)

Oh, thanks! The \u (and \l for lowercase) operators are just what I needed!

Jordi

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