title: PHP explode the string, but treat words in quotes as a single word and ignore brackets
body: <p>I am using the solution from <a href="https://stackoverflow.com/a/2202489/7567785">2202435</a>. But when I add brackets to the string, it doesn't give the right result in the array. </p>
  
  <pre><code> $text = 'Lorem ipsum ("dolor sit amet") consectetur "adipiscing \\"elit" dolor';
  preg_match_all('/"(?:\\\\.|[^\\\\"])*"|\S+/', $text, $matches);
  print_r($matches);
  </code></pre>
  
  <p>The above code produces </p>
  
  <pre><code>   Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Lorem
              [1] =&gt; ipsum
              [2] =&gt; ("dolor
              [3] =&gt; sit
              [4] =&gt; amet")
              [5] =&gt; consectetur
              [6] =&gt; "adipiscing \"elit"
              [7] =&gt; dolor
          )
  
  )
  </code></pre>
  
  <p>But the result I am looking for is</p>
  
  <pre><code>    Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Lorem
              [1] =&gt; ipsum
              [2] =&gt; (
              [3] =&gt; "dolor sit amet"
              [4] =&gt; )
              [5] =&gt; consectetur
              [6] =&gt; "adipiscing \"elit"
              [7] =&gt; dolor
          )
  
  )
  </code></pre>
  
  <p>I am able to achieve the above result, if I include a space after '( ' and before ' )'. </p>
  
  <p>Please advise the correct regex expression that would allow me to keep the brackets seperate (with explanation if possible). </p>
  
  <p>Thank you. </p>