title: Splitting a WHERE sql clause into array
body: <p>I am trying to split a String which is the WHERE clause of a SQL statement into an array with 5 outputs where the following data is hold under each index:</p>
  
  <pre><code>0 - The initial clauses (WHERE/AND/OR) plus any open brackets. e.g "AND((("
  1 - Either the table the first clause comes from or "VALUE" if its a value. e.g. "transactions". 
  2 - The field name or value. e.g. "id"
  3 - The joining value. e.g. &gt;
  4 - Either the table the second clause comes from or "VALUE" if its a value. e.g. "transactions". 
  5 - The field name or value. e.g. "id"
  6 - Any closing brackets. e.g. ")))"
  </code></pre>
  
  <p>For example looping through the following String would output the following arrays:</p>
  
  <pre><code>WHERE transactions.status_code= 'AFA 2'
  AND (transactions.supp_ref = supplier.supp_ref
  AND supplier.supp_addr_ref = address.addr_ref)
  OR transactions.user_code = user.user_code
  
  output[0] = "WHERE"
  output[1] = "transactions"
  output[2] = "status_code"
  output[3] = "="
  output[4] = "VALUE'
  output[5] = "AFA 2"
  output[6] = ""
  
  output[0] = "AND("
  output[1] = "transactions"
  output[2] = "supp_ref"
  output[3] = "="
  output[4] = "supplier"
  output[5] = "supp_ref"
  output[6] = ""
  
  output[0] = "AND"
  output[1] = "supplier"
  output[2] = "supp_addr_ref"
  output[3] = "="
  output[4] = "address"
  output[5] = "addr_ref"
  output[6] = ")"
  
  output[0] = "OR"
  output[1] = "transactions"
  output[2] = "user_code"
  output[3] = "="
  output[4] = "user"
  output[5] = "user_code"
  output[6] = ""
  </code></pre>
  
  <p>For the rest of the SQL statement I have successfully split it up in similar ways using the String.Split method, however due to the variances of the where clause I am having difficulties doing this on this part. From looking around I think I would be better using a Regex expression, but cant work out whats needed. Any help or direction would be much appreciated.</p>