title: How to find all possible regex matches in python?
body: <p>I am trying to find all possible word/tag pairs or other nested combinations with python and its regular expressions.</p>
  
  <pre><code>sent = '(NP (NNP Hoi) (NN Hallo) (NN Hey) (NNP (NN Ciao) (NN Adios)))'
  
  def checkBinary(sentence):
      n = re.findall("\([A-Za-z-0-9\s\)\(]*\)", sentence)
      print(n)
  
  checkBinary(sent)
  
  Output:
  ['(NP (NNP Hoi) (NN Hallo) (NN Hey) (NNP (NN Ciao) (NN Adios)))']
  </code></pre>
  
  <p>looking for:</p>
  
  <pre><code>['(NP (NNP Hoi) (NN Hallo) (NN Hey) (NNP (NN Ciao) (NN Adios)))', 
   '(NNP Hoi)', 
   '(NN Hallo)',
   '(NN Hey)', 
   '(NNP (NN Ciao) (NN Adios))',
   '(NN Ciao)',
   '(NN Adios)']
  </code></pre>
  
  <p>I think the regex formula could find the nested parenthesis word/tag pairs aswell but it doesn't return them. How should I do this?</p>