def _prepRESearchStr(matchStr, wordInitial='ok', wordFinal='ok',
    spanSyllable='ok', stressedSyllable='ok'):
    """
    Prepares a user's RE string for a search
    """
    replList = [(u'ei', u'9'), (u'tʃ', u'='), (u'oʊ', u'~'), (u'dʒ', u'@'),
        (u'aʊ', u'%'), (u'ɑɪ', u'&'), (u'ɔi', u'$')]
    currentReplNum = 0
    startI = 0
    for left, right in (('(', ')'), ('[', ']')):
        while True:
            try:
                i = matchStr.index(left, startI)
            except ValueError:
                break
            j = matchStr.index(right, i) + 1
            replList.append((matchStr[i:j], str(currentReplNum)))
            currentReplNum += 1
            startI = j
    for charA, charB in replList:
        matchStr = matchStr.replace(charA, charB)
    interleaveStr = None
    stressOpt = stressedSyllable == 'ok' or stressedSyllable == 'only'
    spanOpt = spanSyllable == 'ok' or spanSyllable == 'only'
    if stressOpt and spanOpt:
        interleaveStr = u'\\.?ˈ?'
    elif stressOpt:
        interleaveStr = u'ˈ?'
    elif spanOpt:
        interleaveStr = u'\\.?'
    if interleaveStr is not None:
        matchStr = interleaveStr.join(matchStr)
    if wordInitial == 'only':
        matchStr = u'#' + matchStr
    elif wordInitial == 'no':
        matchStr = u'(?:\\.[^\\.#]*?|#[^\\.#]+?)' + matchStr
    else:
        matchStr = u'[#\\.][^\\.#]*?' + matchStr
    if wordFinal == 'only':
        matchStr = matchStr + u'#'
    elif wordFinal == 'no':
        matchStr = matchStr + u'(?:[^\\.#]*?\\.|[^\\.#]+?#)'
    else:
        matchStr = matchStr + u'[^\\.#]*?[#\\.]'
    insertList = []
    for charA, charB in [(u'e', u'i'), (u't', u'ʃ'), (u'd', u'ʒ'), (u'o',
        u'ʊ'), (u'a', u'ʊ|ɪ'), (u'ɔ', u'i')]:
        startI = 0
        while True:
            try:
                i = matchStr.index(charA, startI)
            except ValueError:
                break
            if matchStr[i + 1] != charB:
                forwardStr = u'(?!%s)' % charB
                startI = i + 1 + len(forwardStr)
                insertList.append((i + 1, forwardStr))
    for charA, charB in [(u't', u'ʃ'), (u'd', u'ʒ'), (u'a|o', u'ʊ'), (
        u'e|ɔ', u'i'), u'ɑɪ']:
        startI = 0
        while True:
            try:
                i = matchStr.index(charB, startI)
            except ValueError:
                break
            if matchStr[i - 1] != charA:
                backStr = u'(?<!%s)' % charA
                startI = i + 1 + len(backStr)
                insertList.append((i, backStr))
    insertList.sort()
    for i, insertStr in insertList[::-1]:
        matchStr = matchStr[:i] + insertStr + matchStr[i:]
    for charA, charB in replList:
        matchStr = matchStr.replace(charB, charA)
    replDict = {'D': u'(?:t(?!ʃ)|d(?!ʒ)|[sz])', 'F': u'[ʃʒfvszɵðh]', 'S':
        u'(?:t(?!ʃ)|d(?!ʒ)|[pbkg])', 'N': u'[nmŋ]', 'R': u'[rɝɚ]', 'V':
        u'(?:aʊ|ei|oʊ|ɑɪ|ɔi|[iuæɑɔəɛɪʊʌ]):?', 'B': u'\\.'}
    for char, replStr in replDict.items():
        matchStr = matchStr.replace(char, replStr)
    return matchStr
