Two new template functions: re_group and list_re_group