code: def get_number_matches(self, pattern, source_text='', case=False,
                             regexp=False):
          
          pattern = to_text_string(pattern)
          if not pattern:
              return 0
  
          if not regexp:
              pattern = re.escape(pattern)
  
          if not source_text:
              source_text = to_text_string(self.toPlainText())
  
          try:
              if case:
                  regobj = re.compile(pattern)
              else:
                  regobj = re.compile(pattern, re.IGNORECASE)
          except sre_constants.error:
              return None
  
          number_matches = 0
          for match in regobj.finditer(source_text):
              number_matches += 1
  
          return number_matches
docs: Get the number of matches for the searched text.