code: def scan(self, pattern):
          
          if self.eos:
              raise EndOfText()
          if pattern not in self._re_cache:
              self._re_cache[pattern] = re.compile(pattern, self.flags)
          self.last = self.match
          m = self._re_cache[pattern].match(self.data, self.pos)
          if m is None:
              return False
          self.start_pos = m.start()
          self.pos = m.end()
          self.match = m.group()
          return True
docs: Scan the text for the given pattern and update pos/match
          and related fields. The return value is a boolen that
          indicates if the pattern matched. The matched value is
          stored on the instance as ``match``, the last value is
          stored as ``last``. ``start_pos`` is the position of the
          pointer before the pattern was matched, ``pos`` is the
          end position.