title: How to get all possible combinations of substrings?
body: <p>I have a String of following structure:
  A1(N1,N2,N3)P4(O3,O5)Y1.</p>
  
  <p>How to get all combinations? The rule is that options inside parenthesis should not go together. For this example the output should be:</p>
  
  <pre><code>A1N1P4O3Y1,
  A1N2P4O3Y1,
  A1N3P4O3Y1,
  A1N1P4O5Y1,
  A1N2P4O5Y1,
  A1N3P4O5Y1.
  </code></pre>
  
  <p>There can be parenthesis, but it can be without it. Another example:</p>
  
  <p>N3P5(L1,L2)Q1, output should be:</p>
  
  <pre><code>N3P5L1Q1,
  N3P5L2Q1. 
  </code></pre>
  
  <p>Anyone with elegant solution?</p>