title: How to enum the patterns
body: <p>How to generate all patterns in the following rule:</p>
  
  <p># as a separator, { and } means choose a string between { and }.</p>
  
  <p>For example:</p>
  
  <pre><code>Input: a string
  {a # b} c {d # e {f # g}}
  </code></pre>
  
  <p>Output should be:</p>
  
  <pre><code>a c d
  b c d
  a c e f
  a c e g
  </code></pre>