title: Python string split multiple brackets
body: <p>I am looking for a simpler / faster way to split a string by brackets / parenthesis, as well as removing white spaces and useless info.</p>
  
  <p>More specifically, I want to change</p>
  
  <pre><code>[ 5 * * ]{t=0, 1 }{t=0, 3 }{t=0, 2 }
  </code></pre>
  
  <p>to two part:</p>
  
  <pre><code> 5 * *   (or [ 5 * * ])
  ['1', '3', '2']
  </code></pre>
  
  <p>I managed to do this using my code:</p>
  
  <pre><code>test = '[ 5 * * ]{t=0, 1 }{t=0, 3 }{t=0, 2 }  '
  parsed =  test.split("[")[1].split(']') 
  index = parsed[0]
  content = parsed[1].split('{')[1:]
  seq=[]
  for i in range(len(content)):
      seq.append(content[i][4:-2].replace(' ', ''))   
  print index
  print seq
  </code></pre>
  
  <p>which gets:</p>
  
  <pre><code> 5 * * 
  ['1', '3', '2}']
  </code></pre>
  
  <hr>
  
  <p>I'm looking for suggestions to modify my code. It would be ideal if:</p>
  
  <ol>
  <li><p>There would be <strong>no loop</strong>.</p></li>
  <li><p><strong>Less 'split'</strong>. (There are three 'split' functions in my code)</p></li>
  <li><p><strong>More general</strong>. (I used content[i][4:-2] to remove '{' and '}' which is not general )</p></li>
  </ol>