import re


def inlineEnvMath(s):
    """
    replace the inline latex math mode $ ... $ by the Sphinx one :math:`...`
    """
    rule = '\$(.*?)\$'
    leftLim = ':math:`'
    rightLim = '`'

    p = re.compile(rule)
    #p = re.compile(rule, re.IGNORECASE)

    # ...
    list_data = p.split(s) # split the whole text with respect to the rule
    list_exp  = p.findall(s) # get all expressions to replace

    list_text = ""
    for data in list_data:
        new_data = data
        if data in list_exp:
            new_data = leftLim + data + rightLim
        list_text += new_data

    return list_text