title: Finding nested pairs of brackets in Python
body: <p>The following code will not work in python but works in testing applications like Jedit's plugin "regular expression tester":</p>
  
  <pre><code>import re
  m = "text0 { \int_{0}^{1} f(s) \ds text } text2 {foo-abs2} text4  "
  s = re.compile(r'\{[^{}]*(\{[^{}]*\}[^{}]*)*\}')
  t = s.findall(m)
  print(t) # gives ['{1} f(s) \\ds text ', '']
  """
  Should gives back  
  { \int_{0}^{1} f(s) \ds text }
  {foo-abs2}
  """ 
  </code></pre>
  
  <p>What is wrong?</p>