fork download
  1. <?php
  2.  
  3. $filenames = array(
  4. '/Users/mbpro/Documents/bitbucket/brandpdf/storage/app/uploaded_pdfs/6ab4cc52-c4d4-44dd-9f65-a57eb77e142d/portrait-01.png',
  5. 'Vacation (Me and Mom) (200.png',
  6. 'Vacation (5) (3.png',
  7. );
  8.  
  9. foreach ( $filenames as $filename ) {
  10. if ( preg_match( '/^.*\-(\d+)/s', $filename, $matches ) ) {
  11. echo "$filename => $matches[1]\n";
  12. } else {
  13. echo "$filename => no match!\n";
  14. }
  15. }
  16.  
Success #stdin #stdout 0.03s 26028KB
stdin
Standard input is empty
stdout
/Users/mbpro/Documents/bitbucket/brandpdf/storage/app/uploaded_pdfs/6ab4cc52-c4d4-44dd-9f65-a57eb77e142d/portrait-01.png => 01
Vacation (Me and Mom) (200.png => no match!
Vacation (5) (3.png => no match!