Quote:
Originally Posted by chaley
Now I need to add another function like list_re that uses re_group instead of re. Something like
Code:
list_re_group(src_list, separator, search_re, group_1, group_2, ...)
that would apply the re_group to each item in the list.
|
I submitted this function as well. The prototype is different from what I suggested earlier:
Code:
list_re_group(src_list, separator, include_re, search_re, group_1, group_2, ...)
The function first builds a result list by applying 'include_re' against each list element, then applies re_group(search_re, g1, ...) to each resulting element.
This thread provides an example of this function's use, to uppercase the last name of each author for a book:
Code:
program: list_re_group(field('authors'), ' & ', '.', '([^,]*), (.*)', '{$:uppercase()}, ', '{$}')
or
Code:
{authors:'list_re_group($, ' & ', '.', '([^,]*), (.*)', '[[$:uppercase()]], ', '[[$]]')'}