code: def _simplify(self, pattern):
          # type: (str) -> str
          r
          # remove optional params
          # TODO(dcramer): it'd be nice to change these into [%s] but it currently
          # conflicts with the other rules because we're doing regexp matches
          # rather than parsing tokens
          result = self._optional_group_matcher.sub(lambda m: "%s" % m.group(1), pattern)
  
          # handle named groups first
          result = self._named_group_matcher.sub(lambda m: "{%s}" % m.group(1), result)
  
          # handle non-named groups
          result = self._non_named_group_matcher.sub("{var}", result)
  
          # handle optional params
          result = self._either_option_matcher.sub(lambda m: m.group(1), result)
  
          # clean up any outstanding regex-y characters.
          result = (
              result.replace("^", "")
              .replace("$", "")
              .replace("?", "")
              .replace("//", "/")
              .replace("\\", "")
          )
  
          return result
docs: r"""
          Clean up urlpattern regexes into something readable by humans:
  
          From:
          > "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$"
  
          To:
          > "{sport_slug}/athletes/{athlete_slug}/"