import re


def remove_tag_and_contents(s, tag=None, tags=None):
    """
    >>> remove_tag_and_contents('hi there')
    'hi there'

    >>> remove_tag_and_contents('<p>hi</p> <style>p {font-weight: 400;}</style><p>there</p>', tag='style')
    '<p>hi</p> <p>there</p>'

    >>> remove_tag_and_contents('<span class="foo">hi there</span>', tag='span')
    ''

    >>> remove_tag_and_contents('<p>hi</p> <style>p {font-weight: 400;}</style><p>there</p>', tags=('p', 'style'))
    ' '

    >>> remove_tag_and_contents('<p>hi <span>there</span></p> <style>p {font-weight: 400;}</style><p>cat</p>', tags=('span', 'style'))
    '<p>hi </p> <p>cat</p>'

    >>> remove_tag_and_contents('<p>hi <span class="woot">there</span></p> <style>p {font-weight: 400;}</style><p>cat</p>', tags=('span', 'style'))
    '<p>hi </p> <p>cat</p>'

    >>> remove_tag_and_contents('<p>Hi There<object  classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object></p>', tag='object')
    '<p>Hi There</p>'

    >>> remove_tag_and_contents('<p>Hi </object>there</p>', tag='object')
    '<p>Hi there</p>'

    >>> remove_tag_and_contents('<p>Hi <br/>there</p>', tag='br')
    '<p>Hi there</p>'

    """
    if tag:
        tags = [tag]

    if isinstance(tags, (list, tuple)):
        for t in tags:
            # Tries to match a normal tag structure
            s = re.sub(pattern=r'<{tag}.*?>.*?</{tag}>'.format(tag=t), repl='', string=s)

            # Match any hanging opening or closing versions
            s = re.sub(pattern=r'</{tag}[^>]*>'.format(tag=t), repl='', string=s)
            s = re.sub(pattern=r'<{tag}[^>]*/ *>'.format(tag=t), repl='', string=s)

    return s