import re


def extract_template(pattern):
    """Extracts a 'template' of a url pattern given a pattern
    returns a string

    Example:

    input: '^home/city
      (-(?P<city_name>bristol|bath|cardiff|swindon|oxford|reading))?$'

    output: 'home/city(-{})?'
    """

    pattern = pattern.strip('$^')
    pattern = re.sub(r'\(\?P.+?\)', '{}', pattern)

    return pattern