code: def slugify(string, repchar='_'):
      
      slug_regex = re.compile(r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'.format(repchar))
      strip_regex = re.compile(r'[{0}._-]+'.format(repchar))
  
      transformations = [
          lambda x: slug_regex.sub(repchar, x),
          lambda x: strip_regex.sub(repchar, x),
          lambda x: x.strip(repchar),
          lambda x: x.lower(),
      ]
      result = string
      for process in transformations:
          result = process(result)
  
      return result
docs: replaces all non-alphanumeric chars in the string with the given repchar.
  
      :param string: the source string
      :param repchar: