def remove_text_inside_brackets(s, brackets='()[]'):
    """
    From http://stackoverflow.com/a/14603508/610569
    """
    count = [0] * (len(brackets) // 2)
    saved_chars = []
    for character in s:
        for i, b in enumerate(brackets):
            if character == b:
                kind, is_close = divmod(i, 2)
                count[kind] += (-1) ** is_close
                if count[kind] < 0:
                    count[kind] = 0
                break
        else:
            if not any(count):
                saved_chars.append(character)
    return ''.join(saved_chars)
