title: Python RE Find a Specific Word In a Text Document
body: <p>I'm trying to find a specific word on a line inside a text document using regular expressions. I tried using the below code but it doesn't work properly. </p>
  
  <pre><code>import re
  f1 = open('text.txt', 'r')
  for line in f1:
      m = re.search('(.*)(?&lt;=Dog)Food(.*)', line)
      m.group(0)
      print "Found it."
  f1.close()
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Program Files (x86)\Microsoft Visual Studio 11.0
  ns\Microsoft\Python Tools for Visual Studio\2.0\visualstudi
  0, in exec_file
      exec(code_obj, global_variables)
    File "C:\Users\wsdev2\Documents\Visual Studio 2012\Projec
  TML Head Script\HTML_Head_Script.py", line 6, in &lt;module&gt;
      m.group(0)
  AttributeError: 'NoneType' object has no attribute 'group'
  </code></pre>