code: def match_to_string(self, match, gids, values=None):
          
          s = match.string
          parts = []
          k = 0
          for gid in sorted(gids, key=lambda x: gids[x]):
              if values is None:
                  try:
                      value = self.map_value(match.group(gid), gid)
                      parts.append(s[k:match.start(gid)])
                      parts.append(value)
                      k = match.end(gid)
                  except IndexError:
                      continue
              elif gid in values:
                  parts.append(s[k:match.start(gid)])
                  parts.append(values[gid])
                  k = match.end(gid)
          parts.append(s[k:])
          return u"".join(parts)
docs: Return the mapped string from match object. If a dictionary of
          values is provided then use it to build the string.