title: Check file extensions with Regex
body: <p>I am writing a script to change the name of the video file based on the subtitle files using regular expression.</p>
  
  <pre><code>for files in curDir:
      if re.search(r'.*[.srt]$',files): #1
          print files;
      if re.search(r'.*[^.srt]$',files): #2
          print files;
  </code></pre>
  
  <p>During execution what I found was that the <code>#1</code> if condition is executed continuously so that all the <code>.srt</code> files are printed then only <code>#2</code> if condition is executed and all video files are printed. </p>
  
  <p>Shouldn't those if conditions be executed alternately for each <code>files</code> like first <code>#1</code> and then <code>#2</code>?</p>
  
  <p>I think my problem is the way in which the <code>re.search</code> returns results.
  So, I need help to access the if conditions one after another for each files.           </p>