title: Python Regex "object has no attribute"
body: <p>I've been putting together a list of pages that we need to update with new content (we're switching media formats). In the process I'm cataloging pages that correctly have the new content.  </p>
  
  <p>Here's the general idea of what I'm doing:  </p>
  
  <ol>
  <li>Iterate through a file structure and get a list of files  </li>
  <li>For each file read to a buffer and, using regex search, match a specific tag  </li>
  <li>If matched, test 2 more regex matches  </li>
  <li>write the resulting matches (one or the other) into a database  </li>
  </ol>
  
  <p>Everything works fine up until the 3rd regex pattern match, where I get the following:  </p>
  
  <p><code>'NoneType' object has no attribute 'group'</code></p>
  
  <pre><code># only interested in embeded content
  pattern = "(&lt;embed .*?&lt;/embed&gt;)"
  
  # matches content pointing to our old root
  pattern2 = 'data="(http://.*?/media/.*?")'
  
  # matches content pointing to our new root
  pattern3 = 'data="(http://.*?/content/.*?")'
  
  matches = re.findall(pattern, filebuffer)
  for match in matches:
      if len(match) &gt; 0:
  
      urla = re.search(pattern2, match)
      if urla.group(1) is not None:
          print filename, urla.group(1)
  
      urlb = re.search(pattern3, match)
      if urlb.group(1) is not None:
          print filename, urlb.group(1)
  </code></pre>
  
  <p>thank you.</p>