title: re.search() function in python not finding substring
body: <p>The substring 'Failed to connect to host' is not being found in the 'text' variable. I am fairly new to python and I would appreciate any help. </p>
  
  <pre><code>import subprocess
  import re
  
  host = 'XXXXXXX'
  output = subprocess.Popen(['/usr/bin/ssh', '-q', host, 'ifconfig|', 'grep', 'Mask'], stdout=subprocess.PIPE)
  text = output.communicate()[0].decode('utf-8')
  pattern = 'Failed to connect to host'
  
  if re.search(pattern, text, re.IGNORECASE):
      print('found')
  else:
      print('not found')
  </code></pre>
  
  <p>The expected result should be "found" since the text str contains the pattern but for some reason, the result is "not found".</p>
  
  <p>Actual Output:</p>
  
  <pre><code>Failed to connect to host XXXXXXX port 22: No route to host
  not found
  </code></pre>