Functions within $rreplace

Can functions be used within a $rreplace (regular expression replace) statement?

In my scripts, I am wanting so change the case of some words so, for example, I have

$if($in(%version%,special), $set(version,$rreplace(%version%,special,Special)))

this works, however…

$if($in(%version%,special), $set(version,$rreplace(%version%,\(special\),$title(\\1))))

doesn’t work. Should I be able to use $title within a $rreplace statement in this way?

Obviously with this simple example there is no hardship in the first way, but in more complex statements it would be convenient.

Thanks, Eloise

I don’t think so, but you might get around that by creating a temporary value for the replacement. Something like (untested code):

$setmulti(_words,list; of; words; to; check)
$foreach(%_words%,$set(_temp,$title(%_loop_value%))$set(version,$rreplace(%version%,[^a-zA-Z]\(%_loop_value%\)[^a-zA-Z],%_temp%)))

This should iterate through the list of words defined in the initial $setmulti() statement and title case them in the %version% tag. Note that this should only check the patterns as separate words, and not make the replacements to matches within a word.

1 Like

Thanks… very imaginative work around the issue :slight_smile:

I will have to try that… set ‘ ‘ as the break for elements of a multi-value string.