title: How to filter the output of pexpect
body: <p>In python pexpect, I want to filter the oupt. For example, in the below code I want only the date to be printed.</p>
  
  <pre><code>#!/usr/bin/env python
  import pexpect,time
  p=pexpect.spawn('ssh myusername@192.168.151.80')
  p.expect('Password:')
  p.sendline('mypassword')
  time.sleep(2)
  p.sendline('date')
  p.expect('IST')
  current_date = p.before
  print 'the current date in remote server is: %s' % current_date 
  </code></pre>
  
  <p><strong>Actual output:</strong></p>
  
  <pre><code>the current date in remote server is:
  Last login: Thu Aug 23 22:58:02 2012 from solaris3
  Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
  You have new mail.
  welcome
  -bash-3.00$ date
  Thu Aug 23 23:03:10 
  </code></pre>
  
  <p><strong>Expected output:</strong></p>
  
  <pre><code>the current date in remote server is: Thu Aug 23 23:03:10 
  </code></pre>