import re


def build_doc_index(doc):
    """
    Given a document string, construct index.
    Args:
    doc - a string to be indexed
    Returns:
    a dictionary with key being each distinct word in the doc string 
    and value being a list of positions where this word occurs
    """
    
    doc = doc.lower()
    index = {}
    overallIndex = 0
    splitRegex = '(\W+)'
    
    for word in re.split(splitRegex, doc):
        if (len(word) >= 2 and not re.match(splitRegex, word)):
            if word in index:
                index[word].append(overallIndex)
            else:
                index[word] = [overallIndex]
        overallIndex += len(word)
            
    return index