title: How to get all substrings matching a regex pattern in Python
body: <p>I am using RegEx in Python and I'm having some trouble to find all the substrings matching a given pattern. For example:</p>
  
  <pre><code>import re 
  pattern = '\d{8}[TRWAGMYFPDXBNJZSQVHLCKE]$' 
  text = 'I want to match this two: 01234567A and this 89012345B' 
  </code></pre>
  
  <p>When I apply the RegEx, I would expect to obtain both <code>89012345B</code> and <code>01234567A</code>, but I am only getting the last value (<code>89012345B</code>). What I've tried so far is:</p>
  
  <pre><code>match = re.search(pattern, text)
  print(match.group())
  &gt;&gt;&gt; '89012345B'
  
  match = re.finditer(pattern, text)
  print([match.group() for match in matches])
  &gt;&gt;&gt; ['89012345B']
  
  match = re.findall(pattern, text)
  print(match)
  &gt;&gt;&gt; ['89012345B']
  </code></pre>
  
  <p>As you can see, this only returns the last match. What am I missing? How could I get both?</p>