def ireplace(text, old, new, count=None):
 pattern = re.compile(re.escape(old), re.IGNORECASE)
 if count:
  return pattern.sub(new, text, count=count)
 else:
  return pattern.sub(new, text)

def ireplace ( text , old , new , count = None ) : pattern = re . compile ( re . escape ( old ) , re . IGNORECASE ) if count : return pattern . sub ( new , text , count = count ) else : return pattern . sub ( new , text )
a case-insensitive replace() clone .