title: How to read a snippet from a file using groovy?
body: <p>I am reading a file in groovy using this simple sample code</p>
  
  <pre><code>file.eachLine {line-&gt;
   // do something with line
  }
  </code></pre>
  
  <p>For example my file has some data like this</p>
  
  <pre><code>blah blah blah 
  This is some more lines
  more lines
  Insert into something
  (x1,x2,x3)
  (Select * from
  some table
  where 
  something = something)
  on rowid = something;
  </code></pre>
  
  <p>So I want to read a snippet. 
  If I see a line with rowid that also has a 'semicolon' at the end. then I want to read back till '(select'</p>
  
  <p>So after reading this file I want to have a string that contains:</p>
  
  <pre><code>(Select * from
      some table
      where 
      something = something)
      on rowid = something;
  </code></pre>
  
  <p>Is that possible? and how?</p>