def replace_insensitive(string, target, replacement):
    no_case = string.lower()
    index = no_case.rfind(target.lower())
    if index >= 0:
        return string[:index] + replacement + string[index + len(target):]
    else: # no results so return the original string
        return string
Similar to string.replace() but is case insensitive
dataset/ETHPy150Open dgouldin/django-modernizr/modernizr/middleware.py/replace_insensitive