code: def replace(self, pattern, replacement_pattern, **kwargs):
          
  
          settings = foundations.data_structures.Structure(**{"case_sensitive": False,
                                                              "regular_expressions": False})
          settings.update(kwargs)
  
          selected_text = self.get_selected_text()
          regex = "^{0}$".format(
              pattern if settings.regular_expressions else re.escape(foundations.strings.to_string(pattern)))
          flags = int() if settings.case_sensitive else re.IGNORECASE
          if not selected_text or not re.search(regex, selected_text, flags=flags):
              self.search(pattern, **kwargs)
              return False
  
          cursor = self.textCursor()
          metrics = self.get_selected_text_metrics()
          if cursor.isNull():
              return False
  
          if not cursor.hasSelection():
              return False
  
          cursor.insertText(replacement_pattern)
  
          self.patterns_replaced.emit([metrics])
  
          self.search(pattern, **kwargs)
  
          return True
docs: Replaces current given pattern occurence in the document with the replacement pattern.
  
          Usage::
  
              >>> script_editor = Umbra.components_manager.get_interface("factory.script_editor")
              True
              >>> codeEditor = script_editor.get_current_editor()
              True
              >>> codeEditor.replace(search_pattern, replacement_pattern, case_sensitive=True, whole_word=True, \
  regular_expressions=True, backward_search=True, wrap_around=True)
              True
  
          :param pattern: Pattern to replace.
          :type pattern: unicode
          :param replacement_pattern: Replacement pattern.
          :type replacement_pattern: unicode
          :param \*\*kwargs: Format settings.
          :type \*\*kwargs: dict
          :return: Method success.
          :rtype: bool