code: def _find_and_replace(text, start_string, end_string, replace_fn):
    
    ret = u""
    current_pos = 0
    while True:
      start_pos = text.find(start_string, current_pos)
      if start_pos == -1:
        ret += text[current_pos:]
        break
      ret += text[current_pos:start_pos]
      end_pos = text.find(end_string, start_pos + len(start_string))
      if end_pos == -1:
        break
      ret += replace_fn(text[start_pos + len(start_string):end_pos])
      current_pos = end_pos + len(end_string)
    return ret
docs: Remove everything found between instances of start_string and end_string.
  
    Replace each such instance with replace_fn(removed_text)
  
    e.g. _find_and_replace(u"the [[fat]] cat [[sat]]", u"[[", u"]]", lambda x: x)
      = u"the fat cat sat"
  
    Args:
      text: a unicode string
      start_string: a unicode string
      end_string: a unicode string
      replace_fn: a unary function from unicode string to unicode string
  
    Returns:
      a string