docs: def match(connection, regexp, grouplist=[1], timeout=10):
          '''
          Match against an expression
  
          @param connection: Connection to the host
          @type connection: L{Connection}
  
          @param regexp: compiled regular expression
          @type regexp: L{SRE_Pattern}
  
          @param grouplist: list of groups to return
          @type group: list of int
  
          @param timeout: timeout for performing expect operation
          @type timeout: int
  
          @return: matched string
          @rtype: str
  
          @raises ExpectFailed
          '''
          logging.getLogger('stitches.expect').debug("MATCHING: " + regexp.pattern)
          result = ""
          count = 0
          while count < timeout:
              try:
                  recv_part = connection.channel.recv(32768).decode()
                  logging.getLogger('stitches.expect').debug("RCV: " + recv_part)
                  if connection.output_shell:
                      sys.stdout.write(recv_part)
                  result += recv_part
              except socket.timeout:
                  # socket.timeout here means 'no more data'
                  pass
  
              match = regexp.match(result)
              if match:
                  ret_list = []
                  for group in grouplist:
                      logging.getLogger('stitches.expect').debug("matched: " + match.group(group))
                      ret_list.append(match.group(group))
                  return ret_list
              time.sleep(1)
              count += 1
          raise ExpectFailed(result)