Python does not understand '\1' as a capturing group. You need to use 'match.groups()[0]' to get the first capturing group.
So, just use it like this:
Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
return '<xxspan' + match.groups()[0] + '</xxspan>'