title: Finding a pattern in a list of strings
body: <p>I have an array with headers, and I obtain the headers with the following command:</p>
  
  <pre><code>&gt;&gt;&gt; headers=list(data.dtype.names)
  &gt;&gt;&gt; headers
  ['SqNr', 'Xpos', 'Ypos', 'ALPHA_J2000', 'DELTA_J2000', \
   'UMAG', 'BMAG', 'VMAG', 'RMAG', 'IMAG', 'MB420MAG', \
   'MB464MAG', 'MB485MAG', 'MB518MAG', 'MB571MAG', 'MB604MAG',\
   'MB646MAG', 'MB696MAG', 'MB753MAG', 'MB815MAG', 'MB855MAG',\
   'MB915MAG', 'UMAG_ERR', 'BMAG_ERR', 'VMAG_ERR', 'RMAG_ERR',\
   'IMAG_ERR', 'MB420MAG_ERR', 'MB464MAG_ERR', 'MB485MAG_ERR',\
   'MB518MAG_ERR', 'MB571MAG_ERR', 'MB604MAG_ERR', 'MB646MAG_ERR',\
   'MB696MAG_ERR', 'MB753MAG_ERR', 'MB815MAG_ERR', 'MB855MAG_ERR',\
   'MB915MAG_ERR', 'PHOTOZ', 'PHOTOZ_ERR', 'PHOTOZ2', 'PHOTOZ2_ERR',\
   'Z_B', 'Z_B_MIN', 'Z_B_MAX', 'T_B', 'ODDS', 'CHISQUARED', 'Z_M',\
   'Z_fp', 'Z_sp', 'Z_s']
  </code></pre>
  
  <p>I want to make a list comprises all the strings with <code>MAG</code> pattern at the end and another one contains <code>MAG_ERR</code>. how could I do that?
  I was thinking using the following lines to get the right results:</p>
  
  <pre><code>import re  
  pattern='MAG'
  re.match(r'(%s)+$' % pattern, "".join(headers))
  </code></pre>
  
  <p>but it doesn't return anything. How could I achieve to the right answers which are:</p>
  
  <pre><code>a=['UMAG', 'BMAG', 'VMAG', 'RMAG', 'IMAG', 'MB420MAG',\
     'MB464MAG', 'MB485MAG', 'MB518MAG', 'MB571MAG', 'MB604MAG',\
     'MB646MAG', 'MB696MAG', 'MB753MAG', 'MB815MAG', 'MB855MAG','MB915MAG'] 
  </code></pre>