title: python regex find first word after certain keywords
body: <p>I have the following python code that retrieves first word after certain keywords:</p>
  
  <pre><code>file_tokens = ('DATABASE', 'EXTERNAL_FILE', 'FILE', 'FILENAME', 'INCLUDE')
  # match newline, only spaces, then exact token, then spaces, then everything but whitespace
  search_pattern = r'\n\s*({})\s+([^\s]*)'.format('|'.join(file_tokens))
  matches = re.findall(search_pattern, file_content_string, flags=re.IGNORECASE)  # find matches
  </code></pre>
  
  <p>It is working beautifully in a string like the following (including new lines and carriage returns):</p>
  
  <pre><code># originaly spe1 but with grd ecl file meddled with for nesting 
  include tests
  
  SIMULATION
    SIMULATION_TYPE SUBSURFACE
    PROCESS_MODELS
      SUBSURFACE_FLOW Flow
        MODE BLACK_OIL
        OPTIONS
         ANALYTICAL_JACOBIAN
         ISOTHERMAL
        /
      / ! end of subsurface_flow
    / ! end of process models
    CHECKPOINT
    /
  END  !! end simulation block
  
  SUBSURFACE
  
  external_file example1.dat
  
  include example2.dat
  </code></pre>
  
  <p>with matches containing:</p>
  
  <blockquote>
    <p>matches = [example1.dat, example2.dat]</p>
  </blockquote>
  
  <p>but it is failing for a simple string like the following containing only keywords and other text:</p>
  
  <pre><code>external_file example3.dat
  
  include example4.dat
  </code></pre>
  
  <p>returning an empty array or just the last item (a bit random):</p>
  
  <blockquote>
    <p>matches = [example4.dat] or matches =[]</p>
  </blockquote>
  
  <p>any idea? Thank you. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>OK, after modifying the import text:</p>
  
  <pre><code>external_file example3.dat
  
  include example4.dat
  
  database example5.dat
  </code></pre>
  
  <p>I have realised that my matches array is missing only the first item:</p>
  
  <blockquote>
    <p>matches = [example4.dat, example5.dat]</p>
  </blockquote>
  
  <p>How do I modify the regex to include example3.dat?</p>