if escape_tokens:
    start_token = re.escape(start_token)
end_token = re.escape(end_token)

def replace_with_indent(match):
    indent = match.group(1)
return textwrap.indent(replacement, indent)
return re.sub('^(\\s+)({}[\\s\\S]+?)(?=^\\1{})'.format(start_token,
    end_token), replace_with_indent, source, flags=re.MULTILINE)
src = textwrap.dedent(inspect.getsource(bs4.element.Tag.select))
start_token = "if pseudo_type == 'nth-of-type':"
end_token = 'else'
Extending CSS selectors in BeautifulSoup