title: Regex: gettings all substrings for repeated named group
body: <p>I'm trying to use a named group to retrieve matches from a repeated pattern.
  My code looks like this:</p>
  
  <pre><code>import re
  
  pattern = '(?P&lt;single1&gt;[\w]+?)_((?P&lt;multiple&gt;[\w]+?)_)+(?P&lt;single2&gt;[\w]+?)'
  example = '000_010_020_030_040'
  m = re.match(pattern, example)
  print(m.group('multiple'))
  </code></pre>
  
  <p>This will print <code>030</code>, because previous matches are discarded. What I need is a way to get a list of all the matches. eg.: <code>['010', '020', '030']</code></p>
  
  <p>The <a href="https://pypi.python.org/pypi/regex" rel="nofollow">regex</a> module seems to offer this feature. However I need a solution without external dependencies</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The pattern is generated from user input. The separating characters are not previously known. Neither is the placement of the repeated pattern or the number of non repeated patterns.</p>
  
  <p><strong>Edit2</strong></p>
  
  <p>The following is how the solution can be achieved in the regex module:</p>
  
  <pre><code>import regex
  pattern = '(?P&lt;single1&gt;[\w]+?)_((?P&lt;multiple&gt;[\w]+?)_)+(?P&lt;single2&gt;[\w]+?)'
  m = regex.match(pattern, example)
  print(m.captures('multiple'))
  </code></pre>
  
  <p>returns <code>['010', '020', '030']</code></p>