parameters: (document, search, replace)
return_statement: return newdocument
docstring: Replace all occurences of string with a different string, return updated document
docstring_summary: Replace all occurences of string with a different string, return updated document
docstring_tokens: Replace all occurences of string with a different string return updated document
function: def replace(document, search, replace):
      '''Replace all occurences of string with a different string, return updated document'''
      newdocument = document
      searchre = re.compile(search)
      for element in newdocument.iter():
          if element.tag == '{%s}t' % nsprefixes['w']:  # t (text) elements
              if element.text:
                  if searchre.search(element.text):
                      element.text = re.sub(search, replace, element.text)
      return newdocument
function_tokens: def replace ( document , search , replace ) : newdocument = document searchre = re . compile ( search ) for element in newdocument . iter ( ) : if element . tag == '{%s}t' % nsprefixes [ 'w' ] : # t (text) elements if element . text : if searchre . search ( element . text ) : element . text = re . sub ( search , replace , element . text ) return newdocument