class_docstr: This is regular expression string search helper for the
  spawn.expect_any() method. This helper class is for powerful
  pattern matching. For speed, see the helper class, searcher_string.
  
  Attributes:
  
      eof_index     - index of EOF, or -1
      timeout_index - index of TIMEOUT, or -1
  
  After a successful match by the search() method the following attributes
  are available:
  
      start - index into the buffer, first byte of match
      end   - index into the buffer, first byte after match
      match - the re.match object returned by a successful re.search
class_docstr_tok: ["This","is","regular","expression","string","search","helper","for","the","spawn.expect_any","(",")","method",".","This","helper","class","is","for","powerful","pattern","matching",".","For","speed",",","see","the","helper","class",",","searcher_string",".","Attributes",":","eof_index","-","index","of","EOF",",","or","-1","timeout_index","-","index","of","TIMEOUT",",","or","-1","After","a","successful","match","by","the","search","(",")","method","the","following","attributes","are","available",":","start","-","index","into","the","buffer",",","first","byte","of","match","end","-","index","into","the","buffer",",","first","byte","after","match","match","-","the","re.match","object","returned","by","a","successful","re.search"]
docstr: This searches 'buffer' for the first occurrence of one of the regular
  expressions. 'freshlen' must indicate the number of bytes at the end of
  'buffer' which have not been searched before.
  
  See class spawn for the 'searchwindowsize' argument.
  
  If there is a match this returns the index of that string, and sets
  'start', 'end' and 'match'. Otherwise, returns -1.
docstr_tok: ["This","searches","'buffer","'","for","the","first","occurrence","of","one","of","the","regular","expressions",".","'freshlen","'","must","indicate","the","number","of","bytes","at","the","end","of","'buffer","'","which","have","not","been","searched","before",".","See","class","spawn","for","the","'searchwindowsize","'","argument",".","If","there","is","a","match","this","returns","the","index","of","that","string",",","and","sets","'start","'",",","'end","'","and","'match","'",".","Otherwise",",","returns","-1","."]
code: def search(self, buffer, freshlen, searchwindowsize=None):
      """This searches 'buffer' for the first occurrence of one of the regular
      expressions. 'freshlen' must indicate the number of bytes at the end of
      'buffer' which have not been searched before.
  
      See class spawn for the 'searchwindowsize' argument.
  
      If there is a match this returns the index of that string, and sets
      'start', 'end' and 'match'. Otherwise, returns -1."""
  
      first_match = None
      # 'freshlen' doesn't help here -- we cannot predict the
      # length of a match, and the re module provides no help.
      if searchwindowsize is None:
          searchstart = 0
      else:
          searchstart = max(0, len(buffer) - searchwindowsize)
      for index, s in self._searches:
          match = s.search(buffer, searchstart)
          if match is None:
              continue
          n = match.start()
          if first_match is None or n < first_match:
              first_match = n
              the_match = match
              best_index = index
      if first_match is None:
          return -1
      self.start = first_match
      self.match = the_match
      self.end = self.match.end()
      return best_index
  
imports: import time
  from .exceptions import EOF, TIMEOUT
label_desc: Use image node_id 3 for calling the searcher_re obj's underlying member method code with example usage: obj.search(buffer, freshlen, searchwindowsize) and returns: best_index, unknown