Segment string on separator into list of words.

    Arguments:
        string -- the string we want to process

    Returns:
        words -- list of words the string got minced to
        separator -- the separator char intersecting words
        was_upper -- whether string happened to be upper-case

def _separate_words(string):
    """
    Segment string on separator into list of words.

    Arguments:
        string -- the string we want to process

    Returns:
        words -- list of words the string got minced to
        separator -- the separator char intersecting words
        was_upper -- whether string happened to be upper-case
    """
    words = []
    separator = ""

    # Index of current character. Initially 1 because we don't want to check
    # if the 0th character is a boundary.
    i = 1
    # Index of first character in a sequence
    s = 0
    # Previous character.
    p = string[0:1]

    # Treat an all-caps stringiable as lower-case, so that every letter isn't
    # counted as a boundary.
    was_upper = False
    if string.isupper():
        string = string.lower()
        was_upper = True

    # Iterate over each character, checking for boundaries, or places where
    # the stringiable should divided.
    while i <= len(string):
        c = string[i:i + 1]

        split = False
        if i < len(string):
            # Detect upper-case letter as boundary.
            if UPPER.match(c):
                split = True
            # Detect transition from separator to not separator.
            elif NOTSEP.match(c) and SEP.match(p):
                split = True
            # Detect transition not separator to separator.
            elif SEP.match(c) and NOTSEP.match(p):
                split = True
        else:
            # The loop goes one extra iteration so that it can handle the
            # remaining text after the last boundary.
            split = True

        if split:
            if NOTSEP.match(p):
                words.append(string[s:i])
            else:
                # stringiable contains at least one separator.
                # Use the first one as the stringiable's primary separator.
                if not separator:
                    separator = string[s:s + 1]

                # Use None to indicate a separator in the word list.
                words.append(None)
                # If separators weren't included in the list, then breaks
                # between upper-case sequences ("AAA_BBB") would be
                # disregarded; the letter-run detector would count them as one
                # sequence ("AAABBB").
            s = i

        i += 1
        p = c

    return words, separator, was_upper