def get_inside_outside_brackets(data, start_char, end_char, nested=True):
    """Split string into portions inside and outside delimiters

    Args:
        data: str
            The string to parse
        start_char: str
            Character indicating the beginning of a delimited string
        end_char: str
            Character indicating the end of a delimited string
        nested: bool
            Optional, default True. Whether delimited strings can be nested.
            If True, this method counts the number of start_char and end_char,
            and only ends the delimited string when the number of end_char
            reaches the number of start_char. If False, the first end_char
            ends the delimited string.

    Returns:
        inside, outside: ([str], [str])
            Lists of strings that appear inside and outside the delimiters,
            respectively
    """
    outside = ['']
    inside = []
    in_brackets = False
    count = 0
    for pos, char in enumerate(data):
        if in_brackets:
            if char == end_char:
                count = count - 1
                if count == 0 or not nested:
                    in_brackets = False
                    outside.append('')
                else:
                    inside[-1] = inside[-1] + (char)
            else:
                inside[-1] = inside[-1] + (char)
                if char == start_char:
                    count = count + 1
        elif char == start_char:
            count = 1
            in_brackets = True
            inside.append('')
        else:
            outside[-1] = outside[-1] + char
    outside = [item for item in outside if item]
    return inside, outside