code: def get_regex(resolver_or_pattern):
      
      try:
          regex = resolver_or_pattern.regex
      except AttributeError:
          regex = resolver_or_pattern.pattern.regex
      return regex
docs: Utility method for django's deprecated resolver.regex