title: PHP Regex to extract only portions of different strings
body: <p>I know there are many regex questions on Stackoverflow and I've studied my code again and again but as a newbie to regex and PHP in general I just don't understand. I have a list of file names such as</p>
  
  <blockquote>
    <p>1000032842_WMN_2150_cv.pdf</p>
    
    <p>1000041148_BKO_111_SY_bj.pdf</p>
    
    <p>000048316_ED_3100_AMW_2_a.pdf</p>
    
    <p>1000041231_HF_210_WPO_cr.pdf</p>
  </blockquote>
  
  <p>I am trying to extract the last lowercase characters only: <strong><code>cv</code></strong>, <strong><code>bj</code></strong>, <strong><code>a</code></strong>, <strong><code>cr</code></strong></p>
  
  <p>I am using the following regex to try and do that: <code>[a-z.]+$</code></p>
  
  <p><a href="https://regex101.com/r/zZ1sO7/3" rel="nofollow"><strong>Regex101</strong></a></p>
  
  <p>1) Is the regex correct ?</p>
  
  <p>2) What would be the right php function to use to extra the portion of these strings ? </p>
  
  <p>I have used <code>preg_match</code>, <code>preg_split</code>, but I am not sure which one I should really use. I <em>THINK</em> <code>preg_split</code> is the correct function.</p>
  
  <pre><code>$url = "1000036112_GKV_35_VM_32_a.pdf";
  $url = preg_split('/[a-z.]+$/', $url);
  print_r ($url);
  </code></pre>
  
  <p>but <strong><code>[1]</code></strong> is empty.</p>
  
  <pre><code>Array ( [0] =&gt; 1000036112_GKV_35_VM_32_ [1] =&gt; )
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE EDIT</strong></p>
  
  <p>The following gives a list of int 0, int 1, etc.</p>
  
  <pre><code>&lt;?php
      $filename = "urls.csv";
      $handle = fopen($filename, "r");
      if ($handle !== FALSE) {
          while (($data=fgetcsv($handle,99999,',')) !== FALSE) {
              $url = $data[1];
              var_dump (preg_match_all('/_([a-z]{1,2})\./', $url));
          }
      }
  ?&gt;
  </code></pre>