title: Regular expression to extract SQL query
body: <p>Is there a regex which extracts SQL queries from a string? I'm <strong><em>NOT</em></strong> interested to validate any SQL syntax, rather and only extracting a selection of SQL commands. This to parse a given SQL file/string in a flexible manner.</p>
  
  <p>Given is the following SQL file/string example:</p>
  
  <pre><code>SELECT
      *
  FROM
      test_table
  WHERE
      test_row = 'Testing ; semicolon';
  
  SELECT * FROM another_test_table;
  
  INSERT INTO 
      table_name 
  VALUES 
      (value1,'value which contains semicolon ;;;;',value3,...);
  </code></pre>
  
  <p>Some pseudocode example would be: <code>^(UPDATE|SELECT|INSERT INTO)(.*)(;)$</code>. In the future i'm looking to extend this with all (possible) commands.</p>
  
  <ul>
  <li>Look for a starting match with either: (UPDATE|SELECT|INSERT|INTO)</li>
  <li>Zero or more <code>any character</code> (including whitespaces and newlines)</li>
  <li>Stop at <code>;</code>, which delimits the SQL query.</li>
  </ul>
  
  <p>Whenever this would be possible via a regex the following java code is able to extract all SQL commands:</p>
  
  <pre><code>final String regex = "LOOKING_FOR_THIS_ONE";
  final Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
  final Matcher matcher = p.matcher(content);
  
  while (matcher.find()) {
    // matcher.group() now contains the full SQL command
  }
  </code></pre>
  
  <p>Thanks in advance!</p>