title: Find specific results from a text file
body: <p>Suppose you were reading a text file, with Javascript and jQuery and suppose the server-side guy was unwilling to give you say xml or JSON, and you want to parse the thing once to get relevant text that you will use later in an autocomplete, like so: </p>
  
  <p>Text file (assume there are many similar listings and there are different DATABASES):</p>
  
  <pre><code>QUERY:1
  DATABASE:geoquery
  NL:What are the capitals of the states that border the most populated states?
  SQL:something
  DR:
  root(ROOT-0, What-1)
  cop(What-1, are-2)
  det(capitals-4, the-3)
  nsubj(What-1, capitals-4)
  det(states-7, the-6)
  prep_of(capitals-4, states-7)
  nsubj(border-9, states-7)
  rcmod(states-7, border-9)
  det(states-13, the-10)
  advmod(populated-12, most-11)
  amod(states-13, populated-12)
  dobj(border-9, states-13)
  
  QUERY:2
  DATABASE:geoquery
  NL:What are the capitals of states bordering New York?
  SQL:SELECT state.Capital FROM state JOIN border_info ON state.State_Name        
  DR:
  root(ROOT-0, What-1)
  cop(What-1, are-2)
  det(capitals-4, the-3)
  nsubj(What-1, capitals-4)
  prep_of(capitals-4, states-6)
  partmod(states-6, bordering-7)
  nn(York-9, New-8)
  dobj(bordering-7, York-9)
  </code></pre>
  
  <p>I can use a regex to peel off say all NL: for example, but I need to first pare the file down so only specific NL's associated with a DATABASE get read. So read the file once getting all matches for a specific database that the user selects from a select, then make an array of NL from that list to be the source of an autocomplete. </p>
  
  <pre><code>$(document).ready(function(){
          $.get('inputQueryExamples.txt',function(data){
  
              // need code here to read text file first and limit results 
  
              var queryString = data;
              var cleanString = "";
              cleanString = queryString.match(/^NL.*/gm);
              console.log(cleanString);      
              $('#what').html(cleanString);
  
              var nlString = cleanString.map(function(el) {return el.replace('NL:','');});
  
  
  
  
              $('#query-list').autocomplete({
                  source:nlString
              });
  
          });//end get
  
       });
  </code></pre>
  
  <p>Thanks for any insight. </p>