code: def scan(self, data, part):
          
          if not self.expr.groups:
              for match in self.expr.finditer(data):
                  yield match.group()
  
              self.end = self.end and not bool(data)
          else:
              for match in self.expr.finditer(data):
                  group = self.get_group(match, 'end')
                  if group is not None:
                      if not self.end:
                          yield group
                          yield self.END
                          self.end = True
                  else:
                      self.end = False
                      group = self.get_group(match, 'word')
                      if group is not None:
                          yield group
                      else:
                          yield match.group()
  
          if not part and not self.end:
              if self.default_end is not None:
                  yield self.default_end
              yield self.END
              self.reset()
docs: Scan a string.
  
          Parameters
          ----------
          data : `str`
              String to scan.
          part : `bool`
              `True` if data is partial.
  
          Returns
          -------
          `generator` of (`str` or `markovchain.scanner.Scanner.END`)
              Token generator.