def process_notation(text, sel_start_token='^', sel_end_token='$'):
    '''
    Processes @text assuming it contains markers defining selections.

    @text
      Text that contains @sel_start_token's and @sel_end_token's to define
      selection regions.

    @sel_start_token
      Marks the start of a selection region. Removed from the test.

    @sel_end_token
      Marks the end of a selection region. Removed from the text.

    Reversed selections can be defined too.

    Returns (selections, processed_text), where `selections` are valid ST
            ranges, and `processed_text` is @text without the special symbols.
    '''
    deletions = 0
    start = None
    selections = []
    chars = []

    pos = 0
    while pos < len(text):
        c = text[pos]
        if c == sel_start_token:
            if start == sel_start_token:
                raise ValueError('unexpected token %s at %d', c, pos)
            if start is None:
                start = pos - deletions
            else:
                selections.append(sublime.Region(start, pos - deletions))
                start = None
            deletions += 1
        elif c == sel_end_token:
            if start == sel_end_token:
                raise ValueError('unexpected token %s at %d', c, pos)
            if start is None:
                start = pos - deletions
            else:
                selections.append(sublime.Region(start, pos - deletions))
                start = None
            deletions += 1
        else:
            chars.append(c)
        pos += 1

    if start is not None:
        raise ValueError('wrong format, orphan ^ at %d', start + deletions)
    return selections, ''.join(chars)
dataset/ETHPy150Open guillermooo/Vintageous/tests/cmd_tester.py/process_notation/original