This is an interesting case. In effect, it wants a function that allows a template to be applied to each group matched in the search regular expression, in effect providing similar functionality as python's match groups. This function, having a variable number of arguments, would look something like:
Code:
re_groups(field, search_expr, template_for_group_1, t_for_g_2, ...)
The group would be named '$' when the template for that group is called. The result is the field with each match of 'search_expr' replaced by the result of evaluating the template for each group and concatenating the groups.
For the situation being discussed in this thread and using eschwartz's example, one would use something like
Code:
re_groups(field('author_sort'), '([^,]+), (.+)', 'program: uppercase($)', 'program: $')
or
Code:
re_groups(field('author_sort'), '([^,]+), (.+)', "[[$:uppercase()]]", '[[$]]')
I will look at whether such a function is buildable.