title: Regex getting wrong output in Java
body: <p>I have a string that looks something like:</p>
  
  <blockquote>
    <p>" 'a 'b '(d f g (1 2)) '(3 4) (a d) d "</p>
  </blockquote>
  
  <p>And what I am trying to do is match so I get this output:</p>
  
  <blockquote>
    <p>'a, 'b, '(d f g (1 2)), '(3 4), (a d), d</p>
  </blockquote>
  
  <p>I am currently using:</p>
  
  <pre><code>"'\(.*\)|\(\.*\)|'\w+|\w+"
  </code></pre>
  
  <p>But there is a problem i've runned into using this,
  for example if I write </p>
  
  <blockquote>
    <p>'(a b c) (d f) </p>
  </blockquote>
  
  <p>it will return </p>
  
  <blockquote>
    <p>'(a b c) (d f) </p>
  </blockquote>
  
  <p>instead of </p>
  
  <blockquote>
    <p>'(a b c), (d f)</p>
  </blockquote>
  
  <p>So my question is if there is a way to solve this with regex or do I have to solve this an other way?</p>